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

Class listbox

source code


A mailbox with an unbounded queue.

Instance Methods
 
__init__(self, initial=None)
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
 
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 object from the mailbox.
source code
 
getclose(self, for_put=EOF(), for_get=EOF(), npx=-1, ngx=-1, defer_ex=False)
Get an object from the mailbox and close the mailbox.
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, initial=None)
(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 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.

It does not fill the mailbox. 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

get(self)

source code 

Get an object from the mailbox. This will normally block if the mailbox is empty.

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; 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 

Get an object from the mailbox and close the mailbox. This is normally called by the consumer of data in place of get(). It causes other threads to raise an exception.

Note: It will raise an exception if some other thread has closed the mailbox first.