Fix
This commit is contained in:
@@ -1,4 +1,6 @@
|
|||||||
from tempfile import TemporaryDirectory
|
from tempfile import TemporaryDirectory
|
||||||
|
from typing import Optional, Any
|
||||||
|
|
||||||
import pika
|
import pika
|
||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
@@ -42,6 +44,10 @@ NEW_DATA_RESPONSE = 1097
|
|||||||
tasks = Queue()
|
tasks = Queue()
|
||||||
connected = set()
|
connected = set()
|
||||||
|
|
||||||
|
connection: Optional[pika.BlockingConnection] = None
|
||||||
|
channel: Optional[Any] = None
|
||||||
|
server: Optional[SimpleXMLRPCServer] = None
|
||||||
|
|
||||||
logger = logging.getLogger('xmlrpcserver')
|
logger = logging.getLogger('xmlrpcserver')
|
||||||
|
|
||||||
|
|
||||||
@@ -352,6 +358,8 @@ def pika_callback(ch, method, properties, body):
|
|||||||
|
|
||||||
|
|
||||||
def pika_task():
|
def pika_task():
|
||||||
|
global connection
|
||||||
|
global channel
|
||||||
connection = pika.BlockingConnection(pika.URLParameters(Config.rabbit_conn))
|
connection = pika.BlockingConnection(pika.URLParameters(Config.rabbit_conn))
|
||||||
channel = connection.channel()
|
channel = connection.channel()
|
||||||
channel.basic_consume(queue=Config.rabbit_queue, on_message_callback=pika_callback)
|
channel.basic_consume(queue=Config.rabbit_queue, on_message_callback=pika_callback)
|
||||||
@@ -359,6 +367,7 @@ def pika_task():
|
|||||||
channel.start_consuming()
|
channel.start_consuming()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def list_contents(dir_name):
|
def list_contents(dir_name):
|
||||||
logger.warning('list_contents(%s)', dir_name)
|
logger.warning('list_contents(%s)', dir_name)
|
||||||
return os.listdir(dir_name)
|
return os.listdir(dir_name)
|
||||||
@@ -791,7 +800,8 @@ def bnd_disconnected(bnd_name: str):
|
|||||||
|
|
||||||
|
|
||||||
def xmlrpc_task():
|
def xmlrpc_task():
|
||||||
server = SimpleXMLRPCServer(('0.0.0.0', 9000), logRequests=False, allow_none=True)
|
global server
|
||||||
|
server = SimpleXMLRPCServer(('0.0.0.0', 9000), logRequests=True, allow_none=True)
|
||||||
server.register_function(list_contents)
|
server.register_function(list_contents)
|
||||||
server.register_function(aud_add)
|
server.register_function(aud_add)
|
||||||
server.register_function(auth_response)
|
server.register_function(auth_response)
|
||||||
@@ -889,6 +899,10 @@ async def correction_replication(bnd_name: str, schema: str):
|
|||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
global connection
|
||||||
|
global server
|
||||||
|
global channel
|
||||||
|
|
||||||
logger.setLevel(logging.INFO)
|
logger.setLevel(logging.INFO)
|
||||||
logger.warning('Use Control-C to exit')
|
logger.warning('Use Control-C to exit')
|
||||||
|
|
||||||
@@ -909,6 +923,8 @@ def main():
|
|||||||
uvicorn.run(app, host="0.0.0.0", port=8000)
|
uvicorn.run(app, host="0.0.0.0", port=8000)
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
logger.warning('Exiting')
|
logger.warning('Exiting')
|
||||||
|
finally:
|
||||||
|
server.server_close()
|
||||||
|
|
||||||
|
|
||||||
def vers_key(e):
|
def vers_key(e):
|
||||||
|
|||||||
Reference in New Issue
Block a user