Package gyropy :: Module g_mailbox :: Class mailbox
[frames] | no frames]

Class mailbox

source code


Instance Methods
 
__init__(self)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
close(self, for_put=EOF(), for_get=EOF(), ngx=-1, npx=-1)
Close the connection.
source code
 
__len__(self) source code
 
__nonzero__(self) source code
 
put(self, v)
Put a value into the mailbox.
source code
 
putclose(self, for_get=EOF(), for_put=EOF(), ngx=-1, npx=-1, defer_ex=False)
Close the connection.
source code
 
putraise(self)
Raise any residual exceptions.
source code
 
get(self)
Get an item from the mailbox.
source code
 
getclose(self, for_put=EOF(), for_get=EOF(), npx=-1, ngx=-1, defer_ex=False)
Close the connection.
source code
 
__del__(self) source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables
  eof = EOF()
  ignore = EOF()
Properties

Inherited from object: __class__

Method Details

__init__(self)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

close(self, for_put=EOF(), for_get=EOF(), ngx=-1, npx=-1)

source code 

Close the connection. It causes other threads that use the mailbox to raise an exception, unless you give it self._ignore as an argument. Npx and ngx specify how many threads will commit suicide; zero means none; setting either to 1 is a useful way to kill a single thread.

Legal values for for_put and for_get are any exception, anything returned from sys.exc_info, self.ignore and None.

  • None => Do not raise an exception;
  • self.ignore => Do not change whatever exception (or None) is already stored.

put(self, v)

source code 

Put a value into the mailbox. If one of the close() functions has been used to set an exception on for_put, it will raise the exception instead.

putclose(self, for_get=EOF(), for_put=EOF(), ngx=-1, npx=-1, defer_ex=False)

source code 

Close the connection. This is normally called by the producer of data in place of put(). It can cause other threads to raise an exception.

This call acts like a put() in that it will block until the mailbox is emptied. It does not fill the mailbox, though. Following this call:

  • get() will not block (it will raise an exception unless for_get is self.ignore or npx==0),
  • put() will not block (it will raise an exception if for_put is not self.ignore and npx!=0),
  • likewise putclose() and getclose().

It will raise an exception (unless defer_ex is True) if some other thread has closed first and set a for_put exception. However, it will set a for_get exception (if requested) before expiring.

putraise(self)

source code 

Raise any residual exceptions. This is normally called by the producer of data

This call acts like a put() in that it will block until the mailbox is emptied or until an exception is waiting.

get(self)

source code 

Get an item from the mailbox. Possibly, raise an exception if close or putclose has been called on the mailbox.

Notes:
  • Suicide has a lower priority than processing data. So, if there is data in the mailbox and putclose() has been called, one call to get() will succeed then the second call will raise an exception.
  • If the mailbox is empty, and if a previous call has specified an exception to be raised by readers, raise it.

getclose(self, for_put=EOF(), for_get=EOF(), npx=-1, ngx=-1, defer_ex=False)

source code 

Close the connection. This is normally called by the consumer of data in place of get(). It causes other threads to raise an exception. It will raise an exception if some other thread has closed the mailbox first. Note that if there is something in the mailbox, it will empty and return the value.

Note: If the mailbox is empty, and if a previous call has specified an exception to be raised by readers, raise it.