Remove threaded from examples’ add_event_handler.

This commit is contained in:
Emmanuel Gil Peyrot 2014-08-16 22:37:29 +02:00 committed by Florent Le Coz
parent df68bb4896
commit 476d76a533
12 changed files with 14 additions and 21 deletions

View file

@ -46,8 +46,7 @@ class ActionBot(slixmpp.ClientXMPP):
self._handle_action)) self._handle_action))
self.add_event_handler('custom_action', self.add_event_handler('custom_action',
self._handle_action_event, self._handle_action_event)
threaded=True)
register_stanza_plugin(Iq, Action) register_stanza_plugin(Iq, Action)
@ -77,10 +76,6 @@ class ActionBot(slixmpp.ClientXMPP):
def _handle_action_event(self, iq): def _handle_action_event(self, iq):
""" """
Respond to the custom action event. Respond to the custom action event.
Since one of the actions is to disconnect, this
event handler needs to be run in threaded mode, by
using `threaded=True` in the `add_event_handler` call.
""" """
method = iq['action']['method'] method = iq['action']['method']
param = iq['action']['param'] param = iq['action']['param']

View file

@ -38,7 +38,7 @@ class ActionUserBot(slixmpp.ClientXMPP):
# and the XML streams are ready for use. We want to # and the XML streams are ready for use. We want to
# listen for this event so that we we can initialize # listen for this event so that we we can initialize
# our roster. # our roster.
self.add_event_handler("session_start", self.start, threaded=True) self.add_event_handler("session_start", self.start)
self.add_event_handler("message", self.message) self.add_event_handler("message", self.message)
register_stanza_plugin(Iq, Action) register_stanza_plugin(Iq, Action)

View file

@ -51,7 +51,7 @@ class Disco(slixmpp.ClientXMPP):
# and the XML streams are ready for use. We want to # and the XML streams are ready for use. We want to
# listen for this event so that we we can initialize # listen for this event so that we we can initialize
# our roster. # our roster.
self.add_event_handler("session_start", self.start, threaded=True) self.add_event_handler("session_start", self.start)
def start(self, event): def start(self, event):
""" """

View file

@ -33,7 +33,7 @@ class AvatarDownloader(slixmpp.ClientXMPP):
def __init__(self, jid, password): def __init__(self, jid, password):
slixmpp.ClientXMPP.__init__(self, jid, password) slixmpp.ClientXMPP.__init__(self, jid, password)
self.add_event_handler("session_start", self.start, threaded=True) self.add_event_handler("session_start", self.start)
self.add_event_handler("changed_status", self.wait_for_presences) self.add_event_handler("changed_status", self.wait_for_presences)
self.add_event_handler('vcard_avatar_update', self.on_vcard_avatar) self.add_event_handler('vcard_avatar_update', self.on_vcard_avatar)

View file

@ -37,7 +37,7 @@ class IBBReceiver(slixmpp.ClientXMPP):
# our roster. # our roster.
self.add_event_handler("session_start", self.start) self.add_event_handler("session_start", self.start)
self.add_event_handler("ibb_stream_start", self.stream_opened, threaded=True) self.add_event_handler("ibb_stream_start", self.stream_opened)
self.add_event_handler("ibb_stream_data", self.stream_data) self.add_event_handler("ibb_stream_data", self.stream_data)
def start(self, event): def start(self, event):

View file

@ -34,7 +34,7 @@ class PingTest(slixmpp.ClientXMPP):
# and the XML streams are ready for use. We want to # and the XML streams are ready for use. We want to
# listen for this event so that we we can initialize # listen for this event so that we we can initialize
# our roster. # our roster.
self.add_event_handler("session_start", self.start, threaded=True) self.add_event_handler("session_start", self.start)
def start(self, event): def start(self, event):
""" """

View file

@ -28,7 +28,7 @@ class PubsubClient(slixmpp.ClientXMPP):
self.data = data self.data = data
self.pubsub_server = server self.pubsub_server = server
self.add_event_handler('session_start', self.start, threaded=True) self.add_event_handler('session_start', self.start)
def start(self, event): def start(self, event):
self.get_roster() self.get_roster()

View file

@ -36,7 +36,7 @@ class RegisterBot(slixmpp.ClientXMPP):
# and the XML streams are ready for use. We want to # and the XML streams are ready for use. We want to
# listen for this event so that we we can initialize # listen for this event so that we we can initialize
# our roster. # our roster.
self.add_event_handler("session_start", self.start, threaded=True) self.add_event_handler("session_start", self.start)
# The register event provides an Iq result stanza with # The register event provides an Iq result stanza with
# a registration form from the server. This may include # a registration form from the server. This may include
@ -45,7 +45,7 @@ class RegisterBot(slixmpp.ClientXMPP):
# cases, you will need to examine the fields provided # cases, you will need to examine the fields provided
# and respond accordingly. Slixmpp provides plugins # and respond accordingly. Slixmpp provides plugins
# for data forms and OOB links that will make that easier. # for data forms and OOB links that will make that easier.
self.add_event_handler("register", self.register, threaded=True) self.add_event_handler("register", self.register)
def start(self, event): def start(self, event):
""" """

View file

@ -31,10 +31,8 @@ class RosterBrowser(slixmpp.ClientXMPP):
# the bot establishes its connection with the server # the bot establishes its connection with the server
# and the XML streams are ready for use. We want to # and the XML streams are ready for use. We want to
# listen for this event so that we we can initialize # listen for this event so that we we can initialize
# our roster. We need threaded=True so that the # our roster.
# session_start handler doesn't block event processing self.add_event_handler("session_start", self.start)
# while we wait for presence stanzas to arrive.
self.add_event_handler("session_start", self.start, threaded=True)
self.add_event_handler("changed_status", self.wait_for_presences) self.add_event_handler("changed_status", self.wait_for_presences)
self.received = set() self.received = set()

View file

@ -36,7 +36,7 @@ class SendMsgBot(slixmpp.ClientXMPP):
# and the XML streams are ready for use. We want to # and the XML streams are ready for use. We want to
# listen for this event so that we we can initialize # listen for this event so that we we can initialize
# our roster. # our roster.
self.add_event_handler("session_start", self.start, threaded=True) self.add_event_handler("session_start", self.start)
def start(self, event): def start(self, event):
""" """

View file

@ -29,7 +29,7 @@ class AvatarSetter(slixmpp.ClientXMPP):
def __init__(self, jid, password, filepath): def __init__(self, jid, password, filepath):
slixmpp.ClientXMPP.__init__(self, jid, password) slixmpp.ClientXMPP.__init__(self, jid, password)
self.add_event_handler("session_start", self.start, threaded=True) self.add_event_handler("session_start", self.start)
self.filepath = filepath self.filepath = filepath

View file

@ -24,7 +24,7 @@ class LocationBot(ClientXMPP):
def __init__(self, jid, password): def __init__(self, jid, password):
super(LocationBot, self).__init__(jid, password) super(LocationBot, self).__init__(jid, password)
self.add_event_handler('session_start', self.start, threaded=True) self.add_event_handler('session_start', self.start)
self.add_event_handler('user_location_publish', self.add_event_handler('user_location_publish',
self.user_location_publish) self.user_location_publish)