New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor file locking code for testing #75
Conversation
Only question is naming convention of |
I take that back... The |
pass | ||
if lock_acquired or datetime.now() > start + timedelta(seconds=timeout): | ||
break | ||
time.sleep(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i really don't like this way of implementing a timeout. if the timeout is necessary, we should probably do it some other way...
http://stackoverflow.com/questions/5255220/fcntl-flock-how-to-implement-a-timeout
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can work around it, but it's worth mentioning that the suggested method is somewhat global to the process even if it is better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we have any plans or motivation to multithread Needy itself, so I'd definitely prefer it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's about what I thought. Definitely better to just allow multiple single-threaded Needy instances.
c7c8b32
to
dc04c5d
Compare
Much cleaner. |
fc9f6dc
to
f6660b0
Compare
if not self.__blocking: | ||
return None | ||
print('Waiting for other needy instances to terminate...') | ||
fcntl.flock(self.__fd, fcntl.LOCK_EX) | ||
self.__fd = lock_file(self.__path, timeout=None) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you could leave off the timeout=None
here
Looks good. I'll merge it once Travis approves. |
Removed the |
No description provided.