mirror of
https://github.com/correl/SleekXMPP.git
synced 2024-11-24 03:00:15 +00:00
Merge branch 'develop' of github.com:fritzy/SleekXMPP into develop
This commit is contained in:
commit
b7cd119b0c
3 changed files with 43 additions and 8 deletions
|
@ -140,10 +140,28 @@ class BaseXMPP(XMLStream):
|
||||||
|
|
||||||
def process(self, *args, **kwargs):
|
def process(self, *args, **kwargs):
|
||||||
"""
|
"""
|
||||||
Ensure that plugin inter-dependencies are handled before starting
|
|
||||||
event processing.
|
|
||||||
|
|
||||||
Overrides XMLStream.process.
|
Overrides XMLStream.process.
|
||||||
|
|
||||||
|
Initialize the XML streams and begin processing events.
|
||||||
|
|
||||||
|
The number of threads used for processing stream events is determined
|
||||||
|
by HANDLER_THREADS.
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
block -- If block=False then event dispatcher will run
|
||||||
|
in a separate thread, allowing for the stream to be
|
||||||
|
used in the background for another application.
|
||||||
|
Otherwise, process(block=True) blocks the current thread.
|
||||||
|
Defaults to False.
|
||||||
|
|
||||||
|
**threaded is deprecated and included for API compatibility**
|
||||||
|
threaded -- If threaded=True then event dispatcher will run
|
||||||
|
in a separate thread, allowing for the stream to be
|
||||||
|
used in the background for another application.
|
||||||
|
Defaults to True.
|
||||||
|
|
||||||
|
Event handlers and the send queue will be threaded
|
||||||
|
regardless of these parameters.
|
||||||
"""
|
"""
|
||||||
for name in self.plugin:
|
for name in self.plugin:
|
||||||
if not self.plugin[name].post_inited:
|
if not self.plugin[name].post_inited:
|
||||||
|
|
|
@ -40,9 +40,12 @@ log = logging.getLogger(__name__)
|
||||||
class ClientXMPP(BaseXMPP):
|
class ClientXMPP(BaseXMPP):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
SleekXMPP's client class.
|
SleekXMPP's client class. ( Use only for good, not for evil.)
|
||||||
|
|
||||||
Use only for good, not for evil.
|
Typical Use:
|
||||||
|
xmpp = ClientXMPP('user@server.tld/resource', 'password')
|
||||||
|
xmpp.process(block=False) // when block is True, it blocks the current
|
||||||
|
// thread. False by default.
|
||||||
|
|
||||||
Attributes:
|
Attributes:
|
||||||
|
|
||||||
|
|
|
@ -831,7 +831,7 @@ class XMLStream(object):
|
||||||
self.send_queue.put(data)
|
self.send_queue.put(data)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def process(self, threaded=True):
|
def process(self, **kwargs):
|
||||||
"""
|
"""
|
||||||
Initialize the XML streams and begin processing events.
|
Initialize the XML streams and begin processing events.
|
||||||
|
|
||||||
|
@ -839,14 +839,28 @@ class XMLStream(object):
|
||||||
by HANDLER_THREADS.
|
by HANDLER_THREADS.
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
|
block -- If block=False then event dispatcher will run
|
||||||
|
in a separate thread, allowing for the stream to be
|
||||||
|
used in the background for another application.
|
||||||
|
Otherwise, process(block=True) blocks the current thread.
|
||||||
|
Defaults to False.
|
||||||
|
|
||||||
|
**threaded is deprecated and included for API compatibility**
|
||||||
threaded -- If threaded=True then event dispatcher will run
|
threaded -- If threaded=True then event dispatcher will run
|
||||||
in a separate thread, allowing for the stream to be
|
in a separate thread, allowing for the stream to be
|
||||||
used in the background for another application.
|
used in the background for another application.
|
||||||
Defaults to True.
|
Defaults to True.
|
||||||
|
|
||||||
Event handlers and the send queue will be threaded
|
Event handlers and the send queue will be threaded
|
||||||
regardless of this parameter's value.
|
regardless of these parameters.
|
||||||
"""
|
"""
|
||||||
|
if kwargs.has_key('threaded') and kwargs.has_key('block'):
|
||||||
|
raise ValueError("process() called with both block and threaded arguments")
|
||||||
|
elif kwargs.has_key('block'):
|
||||||
|
threaded = not(kwargs.get('block', False))
|
||||||
|
else:
|
||||||
|
threaded = kwargs.get('threaded', True)
|
||||||
|
|
||||||
self.scheduler.process(threaded=True)
|
self.scheduler.process(threaded=True)
|
||||||
|
|
||||||
def start_thread(name, target):
|
def start_thread(name, target):
|
||||||
|
|
Loading…
Reference in a new issue