Package qubx :: Module singleInstance :: Class SingleInstance
[hide private]
[frames] | no frames]

Class SingleInstance

source code

object --+
         |
        SingleInstance

SingleInstance(port)

Construct this when your app starts, to initiate communication with any duplicates. If it is the only instance, this will start a background server, and pass any args to mySingleInstance.OnArg(arg). If there is an existing instance, this will pass sys.argv[1:] to it.

It is your responsibility to check if mySingleInstance.duplicate, and quit.

example:

>>> import sys, qubx.singleInstance
>>> mySingleInstance = qubx.singleInstance.SingleInstance(MY_APPS_HIGH_PORT_NUMBER)
>>> if mySingleInstance.duplicate:
...     sys.exit(0)
>>> print sys.argv[1:]
Instance Methods [hide private]
 
__init__(port)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
set_OnArg(self, OnArg) source code
 
do_OnArg(self, arg) source code
 
start_serving(self) source code
 
serve(self) source code
 
read(self, client) source code
 
send_args(self, *args) source code

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

Properties [hide private]
  OnArg

Inherited from object: __class__

Method Details [hide private]

__init__(port)
(Constructor)

source code 

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

Overrides: object.__init__
(inherited documentation)

Property Details [hide private]

OnArg

Get Method:
unreachable(s)
Set Method:
set_OnArg(self, OnArg)