Hi,
On 2017年05月22日 10:12, Yikai Lin wrote:
>
>> On May 21, 2017, at 8:45 PM, Iwase Yusuke <[email protected]> wrote:
>>
>> IIRC, Ryu cannot cooperate with the blocking functionality on the C native
>> thread.
>> This constraint is caused by "eventlet" which is networking library and this
>> library
>> is incompatible with the native threads.
>> gevent which is the similar project of eventlet reports this issue;
>> https://github.com/gevent/gevent/issues/786
>>
>> I don't know if possible, I recommend you to use gRPC without blocking mode.
>
> Is it possible to launch regular threads alongside Ryu’s green threads?
> Given that we just need to manage those threads separately
Yes, but please note that it might be complex to handle them.
Please refer to the following snippet.
e.g.)
import eventlet
from ryu.base import app_manager
from ryu.lib import hub
org_threading = eventlet.patcher.original('threading')
org_time = eventlet.patcher.original('time')
class MyRyuApp(app_manager.RyuApp):
def _green_thread_loop(self):
while True:
self.logger.info('*** Green thread sleeping...')
hub.sleep(5)
def _native_thread_loop(self):
while True:
# Simulate blocking behavior by using original "time" module
self.logger.info('*** Native thread sleeping...')
org_time.sleep(10)
def start(self):
super(MyRyuApp, self).start()
self.threads.append(hub.spawn(self._green_thread_loop))
native_thread = org_threading.Thread(target=self._native_thread_loop)
native_thread.start()
Thanks,
Iwase
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel