[BangPypers] real use case of gevent context switch gevent.sleep(0)

2015-06-19 Thread anu sree
Hi, I have seen an example of gevent context switch http://sdiehl.github.io/gevent-tutorial/#synchronous-asynchronous-execution Could you please give some real use case with example. It would be fine If you can share link of github project which uses gevent context gevent.sleep(0). Thanks, _

Re: [BangPypers] real use case of gevent context switch gevent.sleep(0)

2015-06-20 Thread kracekumar ramaraju
Citation from Taskmaster [1], [2]. [1]: https://github.com/dcramer/taskmaster/blob/79a312c5cb3c34d00829fe9cf4204aeb478a0166/src/taskmaster/client.py#L26 [2]: https://github.com/dcramer/taskmaster/blob/79a312c5cb3c34d00829fe9cf4204aeb478a0166/src/taskmaster/server.py#L199 The reason to put sleep(0

Re: [BangPypers] real use case of gevent context switch gevent.sleep(0)

2015-06-20 Thread Noufal Ibrahim KV
On Sat, Jun 20 2015, anu sree wrote: > Hi, > > I have seen an example of gevent context switch > http://sdiehl.github.io/gevent-tutorial/#synchronous-asynchronous-execution > > Could you please give some real use case with example. > It would be fine If you can share link of github project which u

Re: [BangPypers] real use case of gevent context switch gevent.sleep(0)

2015-06-20 Thread anu sree
Thanks naufal and Krace. I have tried following code. I have given gevent.sleep(0.1), that means each greenlet let others to execute 0.1 secoond. But here each greenlet waiting for others to complete, why? Is it because of greenlet.joinall ? Here I have created 3 greenlet threads (A, B, C). I th

Re: [BangPypers] real use case of gevent context switch gevent.sleep(0)

2015-06-20 Thread kracekumar ramaraju
On Sun, Jun 21, 2015 at 5:55 AM, anu sree wrote: > Thanks naufal and Krace. > > I have tried following code. I have given gevent.sleep(0.1), that means > each greenlet let others to execute 0.1 secoond. But here each greenlet > waiting for others to complete, why? Is it because of greenlet.joina

Re: [BangPypers] real use case of gevent context switch gevent.sleep(0)

2015-06-20 Thread anu sree
Hi Krace, I am still not understanding from code (practical example) where we are getting the benefit of PAUSE and let other greenlet to execute. I have created a simple worker program from your example https://github.com/dcramer/taskmaster/blob/79a312c5cb3c34d00829fe9cf4204aeb478a0166/src/taskma

Re: [BangPypers] real use case of gevent context switch gevent.sleep(0)

2015-06-21 Thread Noufal Ibrahim KV
On Sun, Jun 21 2015, anu sree wrote: [...] > This code has two pause (gevent.sleep(0)), in Consumer.start and > Worker.run. Here control goes to Worker.run when Consumer.start > pauses and Consumer.start gets control back when Worker.run > pauses. There may be benefit from this switching, but I

Re: [BangPypers] real use case of gevent context switch gevent.sleep(0)

2015-06-21 Thread anu sree
Thanks noufal, I got it. After gevent.spawn, we have to do join or gevent.joinall or gevent.sleep or patched library call to start the greenlets, right ? I have see the code which not using any of these after gevent.spawn, How it is working there ? https://github.com/Juniper/contrail-controller/

Re: [BangPypers] real use case of gevent context switch gevent.sleep(0)

2015-06-21 Thread Noufal Ibrahim
On 2015-06-21 19:48, anu sree wrote: Thanks noufal, I got it. After gevent.spawn, we have to do join or gevent.joinall or gevent.sleep or patched library call to start the greenlets, right ? join (and joinall) will pause the current greenlet till the ones you've joined terminate (similar t