You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Refer to the documentation, I plan to use asyncio to make an HL7 server, the relevant code is as follows:
importaiorunimportasyncioimporthl7fromhl7.mllpimportstart_hl7_server, HL7StreamReader, HL7StreamWriterasyncdefprocess_hl7_messages(hl7_reader=HL7StreamReader, hl7_writer=HL7StreamWriter):
"""This will be called every time a socket connects with us. """peername=hl7_writer.get_extra_info("peername")
print("Connection established {}".format(peername))
try:
# We're going to keep listening until the writer# is closed. Only writers have closed status.#while not hl7_writer.is_closing():hl7_message=awaithl7_reader.readmessage()
print("Received message:{}".format(hl7_message))
# Now let's send the ACK and wait for the# writer to drainhl7_writer.writemessage(hl7_message.create_ack())
awaithl7_writer.drain()
exceptasyncio.IncompleteReadError:
# Oops, something went wrong, if the writer is not# closed or closing, close it.#if not hl7_writer.is_closing():hl7_writer.close()
awaithl7_writer.wait_closed()
print("Connection closed {}".format(peername))
asyncdefmain():
try:
# Start the server in a with clause to make sure we# close itasyncwithawaitstart_hl7_server(
client_connected_cb=process_hl7_messages, host='10.5.47.17', port=9090
) ashl7_server:
# And now we server forever. Or until we are# cancelled...awaithl7_server.serve_forever()
exceptasyncio.CancelledError:
# Cancelled errors are expectedpassexceptExceptionase:
print("Error occurred in main:", e, e.__class__.__name__,)
aiorun.run(main(), stop_on_unhandled_errors=True)
I commented out :
“while not hl7_writer.is_closing():”
“if not hl7_writer.is_closing():”
since it doesn't seem to be implemented.
environment ubuntu 16.04, Python 3.5.2,when run "python3 server_test.py" the following error occurred:
"Error occurred in main: aexit AttributeError"
Hope someone can help me with this
The text was updated successfully, but these errors were encountered:
Yes, I got the sample from this site:https://python-hl7.readthedocs.io/en/latest/mllp.html. At the same time, I tried again on Python 3.6.9 and found the same error. I checked some information, this error seems to be that if there is no aenter and aexit method in the context manager passed to the async with expression, python seems to throw an error, but I didn't find a solution
Refer to the documentation, I plan to use asyncio to make an HL7 server, the relevant code is as follows:
I commented out :
“while not hl7_writer.is_closing():”
“if not hl7_writer.is_closing():”
since it doesn't seem to be implemented.
environment ubuntu 16.04, Python 3.5.2,when run "python3 server_test.py" the following error occurred:
"Error occurred in main: aexit AttributeError"
Hope someone can help me with this
The text was updated successfully, but these errors were encountered: