Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes | Static Public Attributes
socketserver.ThreadingUDPServer Class Reference
Inheritance diagram for socketserver.ThreadingUDPServer:
Inheritance graph
[legend]
Collaboration diagram for socketserver.ThreadingUDPServer:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def process_request_thread
def process_request
def get_request
def server_activate
def shutdown_request
def close_request
def server_bind
def server_close
def fileno
def serve_forever
def shutdown
def handle_request
def handle_timeout
def verify_request
def process_request
def finish_request
def handle_error

Public Attributes

 socket
 server_address
 RequestHandlerClass

Static Public Attributes

 daemon_threads = False
 allow_reuse_address = False
 socket_type = socket.SOCK_DGRAM
int max_packet_size = 8192
 address_family = socket.AF_INET
int request_queue_size = 5
 timeout = None

Detailed Description

Definition at line 599 of file socketserver.py.


Member Function Documentation

def socketserver.UDPServer.close_request (   self,
  request 
) [inherited]
Called to clean up an individual request.

Reimplemented from socketserver.TCPServer.

Definition at line 491 of file socketserver.py.

00491 
00492     def close_request(self, request):
00493         # No need to close anything.
00494         pass

Here is the caller graph for this function:

def socketserver.TCPServer.fileno (   self) [inherited]
Return socket file number.

Interface required by select().

Definition at line 438 of file socketserver.py.

00438 
00439     def fileno(self):
00440         """Return socket file number.
00441 
00442         Interface required by select().
00443 
00444         """
00445         return self.socket.fileno()

Here is the caller graph for this function:

def socketserver.BaseServer.finish_request (   self,
  request,
  client_address 
) [inherited]
Finish one request by instantiating RequestHandlerClass.

Definition at line 321 of file socketserver.py.

00321 
00322     def finish_request(self, request, client_address):
00323         """Finish one request by instantiating RequestHandlerClass."""
00324         self.RequestHandlerClass(request, client_address, self)

Here is the caller graph for this function:

def socketserver.UDPServer.get_request (   self) [inherited]
Get the request and client address from the socket.

May be overridden.

Reimplemented from socketserver.TCPServer.

Definition at line 479 of file socketserver.py.

00479 
00480     def get_request(self):
00481         data, client_addr = self.socket.recvfrom(self.max_packet_size)
00482         return (data, self.socket), client_addr

Here is the caller graph for this function:

def socketserver.BaseServer.handle_error (   self,
  request,
  client_address 
) [inherited]
Handle an error gracefully.  May be overridden.

The default is to print a traceback and continue.

Reimplemented in idlelib.run.MyRPCServer, and idlelib.rpc.RPCServer.

Definition at line 333 of file socketserver.py.

00333 
00334     def handle_error(self, request, client_address):
00335         """Handle an error gracefully.  May be overridden.
00336 
00337         The default is to print a traceback and continue.
00338 
00339         """
00340         print('-'*40)
00341         print('Exception happened during processing of request from', end=' ')
00342         print(client_address)
00343         import traceback
00344         traceback.print_exc() # XXX But this goes to stderr!
00345         print('-'*40)
00346 

Here is the call graph for this function:

Here is the caller graph for this function:

def socketserver.BaseServer.handle_request (   self) [inherited]
Handle one request, possibly blocking.

Respects self.timeout.

Definition at line 253 of file socketserver.py.

00253 
00254     def handle_request(self):
00255         """Handle one request, possibly blocking.
00256 
00257         Respects self.timeout.
00258         """
00259         # Support people who used socket.settimeout() to escape
00260         # handle_request before self.timeout was available.
00261         timeout = self.socket.gettimeout()
00262         if timeout is None:
00263             timeout = self.timeout
00264         elif self.timeout is not None:
00265             timeout = min(timeout, self.timeout)
00266         fd_sets = select.select([self], [], [], timeout)
00267         if not fd_sets[0]:
00268             self.handle_timeout()
00269             return
00270         self._handle_request_noblock()

Here is the call graph for this function:

Here is the caller graph for this function:

def socketserver.BaseServer.handle_timeout (   self) [inherited]
Called if no new request arrives within self.timeout.

Overridden by ForkingMixIn.

Definition at line 289 of file socketserver.py.

00289 
00290     def handle_timeout(self):
00291         """Called if no new request arrives within self.timeout.
00292 
00293         Overridden by ForkingMixIn.
00294         """
00295         pass

Here is the caller graph for this function:

def socketserver.BaseServer.process_request (   self,
  request,
  client_address 
) [inherited]
Call finish_request.

Overridden by ForkingMixIn and ThreadingMixIn.

Definition at line 304 of file socketserver.py.

00304 
00305     def process_request(self, request, client_address):
00306         """Call finish_request.
00307 
00308         Overridden by ForkingMixIn and ThreadingMixIn.
00309 
00310         """
00311         self.finish_request(request, client_address)
00312         self.shutdown_request(request)

Here is the call graph for this function:

Here is the caller graph for this function:

def socketserver.ThreadingMixIn.process_request (   self,
  request,
  client_address 
) [inherited]
Start a new thread to process the request.

Definition at line 587 of file socketserver.py.

00587 
00588     def process_request(self, request, client_address):
00589         """Start a new thread to process the request."""
00590         t = threading.Thread(target = self.process_request_thread,
00591                              args = (request, client_address))
00592         if self.daemon_threads:
00593             t.daemon = True
00594         t.start()
00595 

Here is the call graph for this function:

def socketserver.ThreadingMixIn.process_request_thread (   self,
  request,
  client_address 
) [inherited]
Same as in BaseServer but as a thread.

In addition, exception handling is done here.

Definition at line 574 of file socketserver.py.

00574 
00575     def process_request_thread(self, request, client_address):
00576         """Same as in BaseServer but as a thread.
00577 
00578         In addition, exception handling is done here.
00579 
00580         """
00581         try:
00582             self.finish_request(request, client_address)
00583             self.shutdown_request(request)
00584         except:
00585             self.handle_error(request, client_address)
00586             self.shutdown_request(request)

Here is the call graph for this function:

Here is the caller graph for this function:

def socketserver.BaseServer.serve_forever (   self,
  poll_interval = 0.5 
) [inherited]
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.

Definition at line 211 of file socketserver.py.

00211 
00212     def serve_forever(self, poll_interval=0.5):
00213         """Handle one request at a time until shutdown.
00214 
00215         Polls for shutdown every poll_interval seconds. Ignores
00216         self.timeout. If you need to do periodic tasks, do them in
00217         another thread.
00218         """
00219         self.__is_shut_down.clear()
00220         try:
00221             while not self.__shutdown_request:
00222                 # XXX: Consider using another file descriptor or
00223                 # connecting to the socket to wake this up instead of
00224                 # polling. Polling reduces our responsiveness to a
00225                 # shutdown request and wastes cpu at all other times.
00226                 r, w, e = select.select([self], [], [], poll_interval)
00227                 if self in r:
00228                     self._handle_request_noblock()
00229         finally:
00230             self.__shutdown_request = False
00231             self.__is_shut_down.set()

Here is the call graph for this function:

def socketserver.UDPServer.server_activate (   self) [inherited]
Called by constructor to activate the server.

May be overridden.

Reimplemented from socketserver.TCPServer.

Definition at line 483 of file socketserver.py.

00483 
00484     def server_activate(self):
00485         # No need to call listen() for UDP.
00486         pass

def socketserver.TCPServer.server_bind (   self) [inherited]
Called by constructor to bind the socket.

May be overridden.

Reimplemented in http.server.HTTPServer, idlelib.rpc.RPCServer, wsgiref.simple_server.WSGIServer, and test.test_wsgiref.MockServer.

Definition at line 411 of file socketserver.py.

00411 
00412     def server_bind(self):
00413         """Called by constructor to bind the socket.
00414 
00415         May be overridden.
00416 
00417         """
00418         if self.allow_reuse_address:
00419             self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
00420         self.socket.bind(self.server_address)
00421         self.server_address = self.socket.getsockname()

Here is the caller graph for this function:

def socketserver.TCPServer.server_close (   self) [inherited]
Called to clean-up the server.

May be overridden.

Reimplemented from socketserver.BaseServer.

Definition at line 430 of file socketserver.py.

00430 
00431     def server_close(self):
00432         """Called to clean-up the server.
00433 
00434         May be overridden.
00435 
00436         """
00437         self.socket.close()

Here is the caller graph for this function:

def socketserver.BaseServer.shutdown (   self) [inherited]
Stops the serve_forever loop.

Blocks until the loop has finished. This must be called while
serve_forever() is running in another thread, or it will
deadlock.

Definition at line 232 of file socketserver.py.

00232 
00233     def shutdown(self):
00234         """Stops the serve_forever loop.
00235 
00236         Blocks until the loop has finished. This must be called while
00237         serve_forever() is running in another thread, or it will
00238         deadlock.
00239         """
00240         self.__shutdown_request = True
00241         self.__is_shut_down.wait()

def socketserver.UDPServer.shutdown_request (   self,
  request 
) [inherited]
Called to shutdown and close an individual request.

Reimplemented from socketserver.TCPServer.

Definition at line 487 of file socketserver.py.

00487 
00488     def shutdown_request(self, request):
00489         # No need to shutdown anything.
00490         self.close_request(request)

Here is the call graph for this function:

Here is the caller graph for this function:

def socketserver.BaseServer.verify_request (   self,
  request,
  client_address 
) [inherited]
Verify the request.  May be overridden.

Return True if we should proceed with this request.

Definition at line 296 of file socketserver.py.

00296 
00297     def verify_request(self, request, client_address):
00298         """Verify the request.  May be overridden.
00299 
00300         Return True if we should proceed with this request.
00301 
00302         """
00303         return True

Here is the caller graph for this function:


Member Data Documentation

socketserver.TCPServer.address_family = socket.AF_INET [static, inherited]

Reimplemented in socketserver.UnixDatagramServer, and socketserver.UnixStreamServer.

Definition at line 394 of file socketserver.py.

socketserver.UDPServer.allow_reuse_address = False [static, inherited]

Reimplemented from socketserver.TCPServer.

Definition at line 473 of file socketserver.py.

socketserver.ThreadingMixIn.daemon_threads = False [static, inherited]

Definition at line 572 of file socketserver.py.

int socketserver.UDPServer.max_packet_size = 8192 [static, inherited]

Definition at line 477 of file socketserver.py.

Definition at line 398 of file socketserver.py.

Definition at line 199 of file socketserver.py.

Reimplemented from socketserver.BaseServer.

Definition at line 420 of file socketserver.py.

Definition at line 405 of file socketserver.py.

socketserver.UDPServer.socket_type = socket.SOCK_DGRAM [static, inherited]

Reimplemented from socketserver.TCPServer.

Definition at line 475 of file socketserver.py.

socketserver.BaseServer.timeout = None [static, inherited]

Reimplemented in test.test_logging.LogRecordSocketReceiver.

Definition at line 194 of file socketserver.py.


The documentation for this class was generated from the following file: