mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-23 00:01:31 +00:00
Move ZMQConnectorBase to networking
This commit is contained in:
parent
dbc2d1c0ea
commit
f5a8230d3b
@ -3,7 +3,7 @@ from zmq.eventloop import ioloop
|
|||||||
from zmq.eventloop.zmqstream import ZMQStream
|
from zmq.eventloop.zmqstream import ZMQStream
|
||||||
|
|
||||||
from tfw.config import tfwenv
|
from tfw.config import tfwenv
|
||||||
from tfw.util import ZMQConnectorBase
|
from tfw.networking.zmq_connector_base import ZMQConnectorBase
|
||||||
|
|
||||||
ioloop.install()
|
ioloop.install()
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ from zmq.eventloop.zmqstream import ZMQStream
|
|||||||
|
|
||||||
from tfw.networking.serialization import serialize_all
|
from tfw.networking.serialization import serialize_all
|
||||||
from tfw.config import tfwenv
|
from tfw.config import tfwenv
|
||||||
from tfw.util import ZMQConnectorBase
|
from tfw.networking.zmq_connector_base import ZMQConnectorBase
|
||||||
|
|
||||||
|
|
||||||
class ServerDownlinkConnector(ZMQConnectorBase):
|
class ServerDownlinkConnector(ZMQConnectorBase):
|
||||||
|
@ -5,7 +5,7 @@ from tfw.networking.serialization import serialize_all
|
|||||||
from tfw.config import tfwenv
|
from tfw.config import tfwenv
|
||||||
from tfw.config.logs import logging
|
from tfw.config.logs import logging
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
from tfw.util import ZMQConnectorBase
|
from tfw.networking.zmq_connector_base import ZMQConnectorBase
|
||||||
|
|
||||||
|
|
||||||
class EventHandlerDownlinkConnector(ZMQConnectorBase):
|
class EventHandlerDownlinkConnector(ZMQConnectorBase):
|
||||||
|
@ -2,7 +2,7 @@ import zmq
|
|||||||
from zmq.eventloop import ioloop
|
from zmq.eventloop import ioloop
|
||||||
|
|
||||||
from tfw.config import tfwenv
|
from tfw.config import tfwenv
|
||||||
from tfw.util import ZMQConnectorBase
|
from tfw.networking.zmq_connector_base import ZMQConnectorBase
|
||||||
from tfw.networking.serialization import serialize_all, deserialize_all
|
from tfw.networking.serialization import serialize_all, deserialize_all
|
||||||
|
|
||||||
ioloop.install()
|
ioloop.install()
|
||||||
|
6
lib/tfw/networking/zmq_connector_base.py
Normal file
6
lib/tfw/networking/zmq_connector_base.py
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
import zmq
|
||||||
|
|
||||||
|
|
||||||
|
class ZMQConnectorBase:
|
||||||
|
def __init__(self, zmq_context=None):
|
||||||
|
self._zmq_context = zmq_context or zmq.Context.instance()
|
@ -1,4 +1,4 @@
|
|||||||
import xmlrpc.client, zmq
|
import xmlrpc.client
|
||||||
from contextlib import suppress
|
from contextlib import suppress
|
||||||
from xmlrpc.client import Fault as SupervisorFault
|
from xmlrpc.client import Fault as SupervisorFault
|
||||||
from time import time, sleep
|
from time import time, sleep
|
||||||
@ -30,11 +30,6 @@ class SupervisorMixin:
|
|||||||
self.start_process()
|
self.start_process()
|
||||||
|
|
||||||
|
|
||||||
class ZMQConnectorBase:
|
|
||||||
def __init__(self, zmq_context=None):
|
|
||||||
self._zmq_context = zmq_context or zmq.Context.instance()
|
|
||||||
|
|
||||||
|
|
||||||
class RateLimiter:
|
class RateLimiter:
|
||||||
def __init__(self, rate_per_second):
|
def __init__(self, rate_per_second):
|
||||||
self.min_interval = 1 / float(rate_per_second)
|
self.min_interval = 1 / float(rate_per_second)
|
||||||
|
Loading…
Reference in New Issue
Block a user