pynetdicom.transport.ThreadedAssociationServer¶
-
class
pynetdicom.transport.ThreadedAssociationServer(ae, address, ssl_context=None)[source][source]¶ An AssociationServer suitable for threading.
-
__init__(ae, address, ssl_context=None)[source]¶ Create a new AssociationServer, bind a socket and start listening.
Parameters: - ae (ae.ApplicationEntity) – The parent AE that’s running the server.
- address (2-tuple) – The (host, port) that the server should run on.
- ssl_context (ssl.SSLContext, optional) – If TLS is to be used then this should be the ssl.SSLContext used to wrap the client sockets, otherwise if None then no TLS will be used (default).
Methods
__init__(ae, address[, ssl_context])Create a new AssociationServer, bind a socket and start listening. close_request(request)Called to clean up an individual request. fileno()Return socket file number. finish_request(request, client_address)Finish one request by instantiating RequestHandlerClass. get_request()Handle a connection request. handle_error(request, client_address)Handle an error gracefully. handle_request()Handle one request, possibly blocking. handle_timeout()Called if no new request arrives within self.timeout. process_request(request, client_address)Start a new thread to process the request. process_request_thread(request, client_address)Process a connection request. serve_forever([poll_interval])Handle one request at a time until shutdown. server_activate()Called by constructor to activate the server. server_bind()Bind the socket and set the socket options. server_close()service_actions()Called by the serve_forever() loop. shutdown()Completely shutdown the server and close it’s socket. shutdown_request(request)Called to shutdown and close an individual request. verify_request(request, client_address)Verify the request. Attributes
address_familyallow_reuse_addressdaemon_threadsrequest_queue_sizesocket_typetimeout-
finish_request(request, client_address)[source]¶ Finish one request by instantiating RequestHandlerClass.
-
get_request()[source]¶ Handle a connection request.
If
ssl_contextis set then the client socket will be wrapped usingssl_context.wrap_socket().Returns: - client_socket (socket._socket) – The connection request.
- address (2-tuple) – The client’s address as (host, port).
-
handle_error(request, client_address)[source]¶ Handle an error gracefully. May be overridden.
The default is to print a traceback and continue.
-
handle_timeout()[source]¶ Called if no new request arrives within self.timeout.
Overridden by ForkingMixIn.
-
serve_forever(poll_interval=0.5)[source]¶ Handle one request at a time until shutdown.
Polls for shutdown every poll_interval seconds. Ignores self.timeout. If you need to do periodic tasks, do them in another thread.
-
server_bind()[source]¶ Bind the socket and set the socket options.
- socket.SO_REUSEADDR is set to 1
- socket.SO_RCVTIMEO is set to AE.network_timeout unless the value is None in which case it will be left unset.
-