Comments (7)
hello @waukeerules , seems very interesting on your issue...
Frankly speaking, I am also fresh on this... unitl now what I only know is my following comments , @niccokunzmann please do not hesitate to point out if I make any mistakes... thanks in advance.
Take the first part of your log as an example, when calling self.queue.put((time.time() + seconds, func, args, kw))
, priorityqueue use heapq
and inside heapq
it uses operator <
to judge for the priority of current input tuple and previous input tuple.
When comparing the tuple, it first judges the first item of tuple : time.time()
, it finds that current tuple and previous tuple has the same value for time.time()
(really amazing here ...) , then it compare the second field of tuple , but this time func
is a method and can not be compared , thus cause the TypeError: '<' not supported between instances of 'method' and 'method'
. (Refer to python code of heapq.py
(function _siftdown(heap, startpos, pos):
)and here for more information.
So , for conclusion,
Seems that the reason why heapq
complains: `TypeError: ' is that there is one tuple in previous priority queue with the same timestamp value of the current input one stored in priorityqueue! sounds really amazing...
Unfortunately, I do not know much about multithread either, but it seems that using current python standard library PriorityQueue
and storing timestamp value in queue ( actually in python list) used as priority identifier may be not a good idea for they may be the same value .....
May be we can find another value used as identifier instead of time.time()
stored in the priorityqueue. Or using a self implement priorityqueue to avoid such a problem^_^
what do u think @niccokunzmann
from python_dhcp_server.
I found that the errors only occur when multiple DHCP requests are initiated at the same exact time.
from python_dhcp_server.
Hello @waukeerules ,
I modify the dhcp.py
, using a simple self-implement PriorityQueue class instead of the official one to avoid the timestamp same value problem. I test it on my bench it works. But for multiple device condition I need your help.
Could you please help me to have a try ? just unzip the file and replace the old one . Hoping for your feedback ! thanks in advance
from python_dhcp_server.
Thanks for reporting this issue! I think, I assumed this case never to turn up.
Yes to this: #12 (comment)
To me, it seems this is the culprit:
python_dhcp_server/server/dhcp.py
Line 139 in 32ba283
In this line 139, I assume that the times are different or at least that the functions can be ordered (which is possible in Python 2 bu not on Python 3).
If we put an additional item in the list, we would also need to change this line:
python_dhcp_server/server/dhcp.py
Line 128 in 32ba283
My solution would be to add a number there which is unique and increased inside a lock, so that there is no multi-threading issue.
_id_lock = threading.Lock()
_id = 0
def get_id():
global _id
with _id_lock:
_id += 1
return _id
As as an answer to #12 (comment), @greggzj if you create a pull request, we can talk about this and even download the source code of it as a zip file and see the change. I do not know what you did and what the change is and this makes it harder for me, in case this is the accepted solution, to add the change into the source code here.
@greggzj @waukeerules, how would you like to go on from here?
from python_dhcp_server.
@niccokunzmann thanks for feedback and sorry for the inconvenience.
I create a pull request #13 and the newly implemented PriorityQueue
class
- no need to modify this line for the self implement priorityqueue class always return item itself exclude the priority identifier index:
python_dhcp_server/server/dhcp.py
Line 128 in 32ba283
- Timestamp value is still used as before.
Seems your solution also works. Which one do u prefer ?
from python_dhcp_server.
Thanks for looking into this issue. I was able to create a simple workaround by changing the queuing method to -first in, first out:
self.queue = queue.Queue()
from python_dhcp_server.
@waukeerules, thanks.... Yep, that is the simplest solution. I used this - the thing is that the packets are re-ordered automatically if it is a queue. So, that is fine and it does not need to be a priority queue.
I am closing this. If anyone finds out that this re-appears, please let me know.
from python_dhcp_server.
Related Issues (16)
- Show assigned IP addresses even if no reply comes HOT 1
- Create a new release 0.5 HOT 1
- Client Identifier != mac HOT 1
- Add ability to bind to a specific IP address HOT 2
- DHCP offers not being accepted HOT 9
- can i reserve ipv6 address HOT 2
- Reuse oldest ip addresses HOT 2
- Create a new release
- How to run without GUI HOT 1
- add slider HOT 8
- remove old ip address entries
- add configuration window
- allow 172.16. .... and 10. ... ip address ranges HOT 3
- DelayWorker keeping server alive HOT 3
- Create a new release 0.4 HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python_dhcp_server.