Right, I narrowed it down to condition.wait being much slower with a
timeout than without.
see attached test script.
On 22 February 2014 08:20, Armin Rigo <[email protected]> wrote:
> Hi Dima,
>
> On 21 February 2014 15:43, Dima Tisnek <[email protected]> wrote:
>> sorry I don't have code handy, it's part of a larger project, but if
>> someone's interested, please reply and I'll hack up a short test case.
>
> Please do.
>
>
> Armin
import time
import logging
import threading
lock = threading.RLock()
ops = 0
class T(threading.Thread):
def run(self):
while True:
with self.cond:
while not self.baton:
#self.cond.wait() # fast
self.cond.wait(10) # slow
global ops
ops += 1
self.next.baton, self.baton = self.baton, None
self.next.cond.notify()
ts = [T() for i in range(2)]
for i, t in enumerate(ts):
t.cond = threading.Condition(lock)
t.baton = None
t.next = ts[(i + 1) % len(ts)]
t.start()
with lock:
ts[0].baton = True
ts[0].cond.notify()
while True:
time.sleep(1)
with lock:
logging.warn("%s ops/s", ops)
ops = 0
_______________________________________________
pypy-dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-dev