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
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
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
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
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
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
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
d8d9e8df16
Fix stanza clobbering when replying to errors.
...
If a stanza handler raised an exception, the exception was processed
and replied by the modified stanza, not a stanza with the original
content.
A copy is now made before handler processing, and if an exception occurs
it is the copy that processes the exception using the original content.
2011-06-20 16:25:56 -07:00
Lance Stout
e219c0f976
Added session_end event and some docs.
...
For now, session_end is the same as disconnected, but once support is
added later for stream management, the two events will become distinct.
Plugins should add handlers for session_end for cleaning any session
state.
2011-06-08 10:24:25 -07:00
Lance Stout
1469323350
Cache stanza if sending fails.
...
The stanza will be sent first once the send queue is reactivated
after session start.
Stanzas sent by skipping the queue will not be cached.
2011-06-01 15:10:44 -07:00
Lance Stout
a81162edd2
Apply connection backoff to reconnect attempts.
...
Backoff was only being done for the initial connection attempt
before. Now any reconnection will start with a minimum 1 sec
delay which will approximately double between attempts.
2011-05-31 10:55:15 -07:00
Lance Stout
8080b4cae2
Cleanup logging and exception handling.
...
The syntax and attribute errors raised during a disconnect/reconnect
attempt are now caught and produce nicer log messages.
2011-05-31 10:23:05 -07:00
Lance Stout
1735c194cd
Don't use the send queue for stream initialization.
...
Use the parameter now=True to skip the queue when
sending Iq stanzas, or using xmpp.send().
2011-05-27 17:00:57 -07:00
Lance Stout
6997b2fbf8
Fix typo for SSL certificate use.
2011-05-27 16:39:45 -07:00
Lance Stout
b81ab97900
Add exponential backoff to connection attempts.
...
Delay will approximately double between attempts (random variation).
See issue #67 .
2011-05-27 14:42:40 -07:00
Lance Stout
384e1a92b7
Added support for testind disconnect errors.
2011-05-27 11:01:30 -07:00
Lance Stout
6244857746
Fix self.disconnect(reconnect=True) not working.
2011-03-18 15:47:21 -04:00
Lance Stout
4df3aa569b
Bring back the signal handlers (and the "killed" event).
...
Now done more responsibly, saving any existing signal handlers
and calling them when an interrupt occurs in addition to the
one Sleek installs.
NOTE: You may need to explicitly use "kill <process id>" in
order to trigger the proper signal handler execution, and
to raise the "killed" event.
2011-02-23 10:20:04 -05:00
Lance Stout
d709f8db65
Use the _build_stanza method.
2011-02-14 13:50:59 -05:00
Lance Stout
75584d7ad7
Remap old method names in a better way.
...
This should prevent some reference cycles that will cause garbage
collection issues.
2011-02-14 13:49:43 -05:00
Lance Stout
8b5511c7ec
Simplification when removing a deletable handler.
2011-02-13 16:40:04 -05:00
Lance Stout
38dc35840e
Recognize stanzas that don't use the default namespace.
2011-01-27 15:59:50 -05:00
Lance Stout
cb85d4a529
Raise the event 'socket_error' when a socket error occurs.
...
Will be most useful for debugging and responding to failed
connection attempts.
2011-01-16 13:07:39 -05:00
Lance Stout
d7dea0c6cc
Add a note for debug statement when running scheduled events.
...
Fixes the intermittent DEBUG ((),) messages that give no
explanation.
Will now show as:
DEBUG Scheduled event: ((), )
2011-01-14 12:07:25 -05:00
Lance Stout
34c374a1e1
Make tests pass for catching exceptions.
...
May now use sys.excepthook to catch exceptions
from threaded handlers.
2010-12-17 13:11:03 -05:00