mirror of
https://github.com/faucetsdn/ryu.git
synced 2026-05-07 21:36:10 +02:00
yield the CPU to other greenlets
We need to yield the CPU to other greenlets. Otherwise, ryu can't accept new switches or handle the existing switches. The limit is arbitrary. I guess that we need to think about the better approach in the future (e.g. non greenlet framework). Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
parent
f6741e9c93
commit
d7ee5d2282
@ -114,6 +114,7 @@ class Datapath(object):
|
||||
buf = bytearray()
|
||||
required_len = ofproto.OFP_HEADER_SIZE
|
||||
|
||||
count = 0
|
||||
while self.is_active:
|
||||
ret = self.socket.recv(required_len)
|
||||
if len(ret) == 0:
|
||||
@ -134,6 +135,15 @@ class Datapath(object):
|
||||
buf = buf[required_len:]
|
||||
required_len = ofproto.OFP_HEADER_SIZE
|
||||
|
||||
# We need to schedule other greenlets. Otherwise, ryu
|
||||
# can't accept new switches or handle the existing
|
||||
# switches. The limit is arbitrary. We need the better
|
||||
# approach in the future.
|
||||
count += 1
|
||||
if count > 2048:
|
||||
count = 0
|
||||
gevent.sleep(0)
|
||||
|
||||
@_deactivate
|
||||
def _send_loop(self):
|
||||
while self.is_active:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user