Commit graph

258 commits

Author SHA1 Message Date
Lance Stout
fba60ffff1 Convert daemon threads back into normal threads.
This may need to be reverted if CTRL-C handling breaks, but everything
works fine so far in testing.

Resolves issue #95.
2011-11-20 12:17:35 -08:00
Lance Stout
d1a945a305 Tidy up logging some more 2011-11-19 19:18:43 -08:00
Lance Stout
685b9ab102 Fix logging exceptions from formatting issues. 2011-11-19 19:08:27 -08:00
Lance Stout
24f27c0fe3 Pass generic connection errors to XMLStream.exception() 2011-11-19 19:01:07 -08:00
Lance Stout
3019c82d8a Use a list comprehension instead of filter() to work with Python3. 2011-11-19 18:49:18 -08:00
Lance Stout
b54cc97e4c Merge remote-tracking branch 'vijayp/master' into HEAD
Conflicts:
	examples/ping.py
	sleekxmpp/basexmpp.py
	sleekxmpp/clientxmpp.py
	sleekxmpp/features/feature_bind/bind.py
	sleekxmpp/features/feature_mechanisms/mechanisms.py
	sleekxmpp/plugins/gmail_notify.py
	sleekxmpp/plugins/jobs.py
	sleekxmpp/plugins/xep_0009/remote.py
	sleekxmpp/plugins/xep_0009/rpc.py
	sleekxmpp/plugins/xep_0012.py
	sleekxmpp/plugins/xep_0045.py
	sleekxmpp/plugins/xep_0050/adhoc.py
	sleekxmpp/plugins/xep_0078/legacyauth.py
	sleekxmpp/plugins/xep_0085/chat_states.py
	sleekxmpp/plugins/xep_0199/ping.py
	sleekxmpp/plugins/xep_0224/attention.py
	sleekxmpp/xmlstream/handler/waiter.py
	sleekxmpp/xmlstream/matcher/xmlmask.py
	sleekxmpp/xmlstream/xmlstream.py

Conflicts:
	examples/ping.py
	sleekxmpp/basexmpp.py
	sleekxmpp/clientxmpp.py
	sleekxmpp/features/feature_bind/bind.py
	sleekxmpp/features/feature_mechanisms/mechanisms.py
	sleekxmpp/plugins/gmail_notify.py
	sleekxmpp/plugins/jobs.py
	sleekxmpp/plugins/xep_0009/remote.py
	sleekxmpp/plugins/xep_0009/rpc.py
	sleekxmpp/plugins/xep_0012.py
	sleekxmpp/plugins/xep_0045.py
	sleekxmpp/plugins/xep_0050/adhoc.py
	sleekxmpp/plugins/xep_0078/legacyauth.py
	sleekxmpp/plugins/xep_0085/chat_states.py
	sleekxmpp/plugins/xep_0199/ping.py
	sleekxmpp/plugins/xep_0224/attention.py
	sleekxmpp/xmlstream/handler/waiter.py
	sleekxmpp/xmlstream/matcher/xmlmask.py
	sleekxmpp/xmlstream/xmlstream.py
2011-11-19 18:23:26 -08:00
Vijay Pandurangan
e3b9d5abbf double copy 2011-11-19 16:03:17 -08:00
Vijay Pandurangan
2332970cf2 elide unnecessary copy 2011-11-19 16:02:41 -08:00
Vijay Pandurangan
48af3d3322 remove unnecessary copies when only one handler matches. This was taking up ~ 15% of CPU on moderate load. 2011-11-19 15:59:38 -08:00
Lance Stout
429c94d6a9 Tidy up logging calls. 2011-11-19 12:07:57 -08:00
Vijay Pandurangan
deb52ad350 This change stops sleekxmpp from spending huge amounts of time unnecessarily computing logging data that may never be used. This is a HUGE performance improvement; in some of my test runs, unnecessary string creation was accounting for > 60% of all CPU time.
Note that using % in a string will _always_ perform the sting substitutions, because the strings are constructed before the function is called. So log.debug('%s' % expensiveoperation()) will take about the same CPU time whether or not the logging level is DEBUG or INFO. if you use , no substitutions are performed unless the string is actually logged
2011-11-20 03:39:05 +08:00
Vijay Pandurangan
6f3cc77bb5 This change stops sleekxmpp from spending huge amounts of time unnecessarily computing logging data that may never be used. This is a HUGE performance improvement; in some of my test runs, unnecessary string creation was accounting for > 60% of all CPU time.
Note that using % in a string will _always_ perform the sting substitutions, because the strings are constructed before the function is called. So log.debug('%s' % expensiveoperation()) will take about the same CPU time whether or not the logging level is DEBUG or INFO. if you use , no substitutions are performed unless the string is actually logged
2011-11-19 11:30:44 -08:00
Lance Stout
0c86f8288d No need to continue processing loop if an error ocurred and auto_reconnect=False. 2011-11-14 11:21:05 -08:00
Lance Stout
43c4d23896 Explicitly test for inequality in JIDs.
Fixes issue #113
2011-11-14 09:15:43 -08:00
Lance Stout
b8efcc7cf0 Don't just call self.disconnect in self.reconnect.
It messes up the auto_reconnect value and causes the XML processing
loop to spin wildly with errors on a stream disconnect.
2011-11-08 19:23:53 -08:00
Lance Stout
888e286a09 Continue trying to reconnect, even if the attempt fails.
The transition from disconnected to connected states must be done in a
loop in case the transition fails, not just once and hope it worked.
2011-11-07 01:13:34 -08:00
Lance Stout
335dc2927b Break reference cycle to fix potential memory leaks for callback handlers. 2011-10-08 17:31:30 -04:00
Lance Stout
262da78ca7 Fix del_event_handler for Python3 (different semantics for filter()).
Fixes issue #103
2011-09-23 12:03:49 -04:00
Lance Stout
0b83edf439 Fix regression for handling the case where the server terminates the stream.
The processing loop was continuing to call __read_xml after </stream>
was received, which caused SyntaxErrors (can't find starting element).

This should fix issue #102
2011-09-22 01:32:44 -04:00
Nathan Fritz
cf7fcf496e SyntaxError requires a restart 2011-09-19 11:53:09 -07:00
Lance Stout
6f72c05ebf Add whitespace keepalive option.
May be disabled by setting:
    self.whitespace_keepalive = False

The keepalive interval can be adjusted using:
    self.whitespace_keepalive_interval = 300

The default interval is 5min.
2011-09-01 16:24:09 -07:00
Lance Stout
0af35c2224 Fix memory reference bugs. 2011-09-01 00:50:45 -07:00
Lance Stout
e3e985220e Simplify the main process loop. 2011-08-25 17:08:20 -07:00
Lance Stout
802dd8393d Make the timeout for event queue checks configurable.
Now defaults xmlstream.WAIT_TIMEOUT, and settable with
self.wait_timeout.

The new default timeout is 1sec instead of 5sec.
2011-08-25 16:45:34 -07:00
Lance Stout
fe6bc31c60 Added XMLStream.configure_dns.
This can be overridden to do custom configuration for the DNS resolver,
or any other DNS related tasks such as calling the system's res_init().
2011-08-25 16:18:26 -07:00
Lance Stout
2162d6042e Session timeout now defaults to 45sec, but can be adjusted.
e.g.

    self.session_timeout = 15

It is also managed by XMLStream instead of ClientXMPP now.
2011-08-25 15:40:13 -07:00
Lance Stout
b8a4ffece9 Handle sending stanzas in chunks if the socket has poor performance. 2011-08-25 15:08:45 -07:00
Lance Stout
d929e0deb2 Shutdown socket before closing. 2011-08-25 13:48:43 -07:00
Lance Stout
4c08c9c524 Update scheduler with locks and ability to remove tasks.
Scheduled tasks must have a unique name.
2011-08-25 13:34:30 -07:00
Lance Stout
63b8444abe Add overridable method self.configure_socket().
Allows for setting app specific socket timeouts and other socket options.
2011-08-25 00:22:26 -07:00
Lance Stout
84f9505a8d Fix handling of DNS exceptions. 2011-08-24 22:40:57 -07:00
Lance Stout
e02a42a008 Route all unhandled exceptions through XMLStream.exception.
Or through an equivalent override.
2011-08-18 16:12:51 -07:00
Lance Stout
3e51126e18 PEP8 edits 2011-08-18 02:46:48 -07:00
Lance Stout
e86e6eae81 Up the timeout to 30sec instead of 10sec. 2011-08-18 01:10:25 -07:00
Nathan Fritz
f75b6bf955 added inline documentation for new dns methods 2011-08-18 01:04:01 -07:00
Lance Stout
cd7cd30b4c Fix exceptions for Python3 2011-08-18 00:47:07 -07:00
Nathan Fritz
3853898ab3 DNS is now properly checked and different answers are tried for each reconnect until exhausted 2011-08-18 00:35:18 -07:00
Lance Stout
9fdd85d9f1 I've seen people complain about Sleek taking so long to disconnect.
Added logging to say that we're waiting for the server to end the stream
from its end.
2011-08-13 08:58:07 -07:00
Lance Stout
bd427849fb Reduce the maximum delay between connection retries to 10min. 2011-08-12 17:17:05 -07:00
Lance Stout
47bc50d9fb Cosmetic PEP8 fixes. 2011-08-04 22:37:22 -07:00
Lance Stout
93a4a3f8a0 Fix Python3 issue with dict.has_key() 2011-08-04 22:36:23 -07:00
Nathan Fritz
7f90de887a added block as process option and updated documentation. added typical use example to ClientXMPP. 2011-08-04 21:49:32 -07:00
Lance Stout
b9764cc120 Clean up and unify tostring once and for all.
Packaging for Python3 just got easier.
2011-08-04 11:41:36 -07:00
Lance Stout
d94517d9ca Merge branch 'develop' into stream_features 2011-08-03 17:37:15 -07:00
Lance Stout
3918ddb075 Merge branch 'develop' into stream_features 2011-08-03 17:02:33 -07:00
Lance Stout
e022b2a36c Add support for HTTP Proxy connections. 2011-07-27 19:35:03 -07:00
Lance Stout
5efb170e1d Added wait parameter to disconnect.
If wait=True, then the disconnect call will block until
the send queue has emptied.

WARNING: Using wait=True when more stanzas are being added to the
queue than can be processed such that the queue is never empty
will cause the disconnect call to block indefinitely without actually
disconnecting.
2011-07-04 18:47:57 -07:00
Lance Stout
04def6d925 Merge branch 'develop' into stream_features 2011-07-01 15:19:37 -07:00
Lance Stout
2a2ac73845 So using sys.excepthook to catch errors only works once.
The error bubbles through the event processing loop, breaking it and
hanging the application.

Instead, there is now a .exception(e) method on XMLStream which may
be overridden or reassigned that will receive all unhandled exceptions
(read: not XMPPError) from event and stream handlers.
2011-07-01 15:18:10 -07:00
Lance Stout
fa716457a5 Merge branch 'develop' into stream_features 2011-06-20 16:27:55 -07:00