opened
rhdxmr
username_0
A process which created znode of lowest sequence number calls wait_on_sibling method multiple times in the loop, but the previous code does not subtract already spent time from given timeout.

Refactoring DoubleBarrier.leave based on the official zookeeper document.

Also some tests are added.
Fix timeout accuracy of DoubleBarrier.leave
issue
created
cybergrind
username_1
hey @username_0 
Initially, there was another approach with a time-limit, which I've removed it because of incorrect implementation (thus almost infinite timeout values) here https://github.com/micro-fan/aiozk/commit/e6dc661e832543658cd475aa9760e5bc3210762d

So, there are more places like that.
1. Could you please check the commit above, probably it is worth to add more places
2. Looking at the implementation, probably we could move it to separate context manager that can be used like

```python
with deadline_timeout(initial_timeout) as dt:
    wait_for(dt(), some_action1)  # dt() will just return initial_timeout
    wait_for(dt(), some_action2)  # dt() will return initial_timeout - time of some_action1
```
3. I'm not sure that `time.perf_counter` is really better than `time.time` for our case. Also it is way more cryptic than regular unix-timestamp. So, probably, it is better to use `time.time` instead.
comment
created
rhdxmr
username_0
@username_1 OK. As you said, I am going to find other places for applying the same timeout mechanism.

And your suggestion of that using context manager or generator sounds very nice.
I'll come up with reasonable solution.🙂
Thanks
comment
created
rhdxmr
username_0
@username_1 I sent new commit. Please check this PR

As you said, I agree with that time.perf_counter is more cryptic than time.time at python level. So I use time.time instead of time.perf_counter.

For reference, I investigated the difference between them. In Linux, time.perf_counter calls a system call clock_gettime(CLOCK_MONOTONIC) and time.time calls clock_gettime(CLOCK_REALTIME). At this level, it is reasonable to use clock_gettime(CLOCK_MONOTONIC) because we just need the difference between 2 time. But at python level, it is not obvious.

First I considered to make use of context manager as you mentioned. But I thought the timeout feature does not deserve more indentations for with-statement. If it is a context manager, every code that uses it should have more indentation. I think it is inconvenient. And in addition it does not have any resources to release.

But if I had to raise an exception after timeout, I would make use of context manager.

So I made a new class for this feature: Deadline class.
comment
created
cybergrind
username_1
:+1: released as 0.25.0. Good job, thank you
comment