pynetdicom.transport.ThreadedAssociationServer

class pynetdicom.transport.ThreadedAssociationServer(ae: ApplicationEntity, address: Tuple[str, int], ae_title: str, contexts: List[PresentationContext], ssl_context: Optional[ssl.SSLContext] = None, evt_handlers: List[Union[Tuple[Union[NotificationEvent, InterventionEvent], Callable], Tuple[Union[NotificationEvent, InterventionEvent], Callable, List[Any]]]] = None, request_handler: Optional[Callable[[...], BaseRequestHandler]] = None)[source]

An AssociationServer suitable for threading.

New in version 1.2.

__init__(ae: ApplicationEntity, address: Tuple[str, int], ae_title: str, contexts: List[PresentationContext], ssl_context: Optional[ssl.SSLContext] = None, evt_handlers: List[Union[Tuple[Union[NotificationEvent, InterventionEvent], Callable], Tuple[Union[NotificationEvent, InterventionEvent], Callable, List[Any]]]] = None, request_handler: Optional[Callable[[...], BaseRequestHandler]] = None) 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 (Tuple[str, int]) – The (host: str, port: int) that the server should run on.

  • ae_title (str) – The AE title of the SCP.

  • contexts (list of presentation.PresentationContext) – The SCPs supported presentation contexts.

  • 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).

  • evt_handlers (list of 2- or 3-tuple, optional) – A list of (event, callable) or (event, callable, args), the callable function to run when event occurs and the optional extra args to pass to the callable.

  • request_handler (type) – The request handler class; an instance of this class is created for each request. Should be a subclass of BaseRequestHandler.

Methods

__init__(ae, address, ae_title, contexts[, ...])

Create a new AssociationServer, bind a socket and start listening.

bind(event, handler[, args])

Bind a callable handler to an event.

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_events()

Return a list of currently bound events.

get_handlers(event)

Return handlers bound to a specific event.

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()

Close the server.

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.

unbind(event, handler)

Unbind a callable handler from an event.

verify_request(request, client_address)

Verify the request.

Attributes

active_associations

Return the server's running Association acceptor instances

address_family

allow_reuse_address

block_on_close

daemon_threads

request_queue_size

socket_type

ssl_context

Return the ssl.SSLContext (if available).

timeout

process_request_thread(request: Union[socket, Tuple[bytes, socket]], client_address: Union[Tuple[str, int], str]) None[source]

Process a connection request.