Philipp Hörist pushed to branch master at gajim / python-nbxmpp
Commits:
3759d612 by Jeff 'Raid' Baitis at 2018-01-22T11:49:37-08:00
Unit test the SelectIdleQueue (and not an unusued implementation)
- - - - -
bf7f89a6 by Jeff 'Raid' Baitis at 2018-01-22T11:49:37-08:00
Correct logic error in code that checks for infile handles
- - - - -
9a1b179d by Jeff 'Raid' Baitis at 2018-01-22T11:49:37-08:00
Remove unused implementation of process() in the superclass.
- - - - -
9d40e12a by Jeff 'Raid' Baitis at 2018-01-22T11:49:37-08:00
Make file flags consistent with the two different implementations of
IOQueue as using hard-coded integer values makes some assumptions about
the underlying GLIB implementation.
- - - - -
aba046ac by Jeff 'Raid' Baitis at 2018-01-22T11:49:37-08:00
Formatting clean-up and additional comments regarding flags for clarity
- - - - -
5a37180d by Philipp Hörist at 2018-01-23T23:38:48+01:00
Merge branch 'master' into 'master'
Cleanups, fix for logic error in code that checks for invalid file handles
See merge request gajim/python-nbxmpp!13
- - - - -
2 changed files:
- nbxmpp/idlequeue.py
- test/lib/xmpp_mocks.py
Changes:
=====================================
nbxmpp/idlequeue.py
=====================================
--- a/nbxmpp/idlequeue.py
+++ b/nbxmpp/idlequeue.py
@@ -44,21 +44,23 @@ elif os.name == 'posix':
import fcntl
if sys.version_info[0] == 2 or not HAVE_GLIB:
- FLAG_WRITE = 20 # write only
- FLAG_READ = 19 # read only
- FLAG_READ_WRITE = 23 # read and write
- FLAG_CLOSE = 16 # wait for close
+ FLAG_WRITE = 20 # write only 10100
+ FLAG_READ = 19 # read only 10011
+ FLAG_READ_WRITE = 23 # read and write 10111
+ FLAG_CLOSE = 16 # wait for close 10000
+ PENDING_READ = 3 # waiting read event 11
+ PENDING_WRITE = 4 # waiting write event 100
+ IS_CLOSED = 16 # channel closed 10000
else:
FLAG_WRITE = GLib.IOCondition.OUT | GLib.IOCondition.HUP
- FLAG_READ = GLib.IOCondition.IN | GLib.IOCondition.PRI | \
- GLib.IOCondition.HUP
+ FLAG_READ = GLib.IOCondition.IN | GLib.IOCondition.PRI | \
+ GLib.IOCondition.HUP
FLAG_READ_WRITE = GLib.IOCondition.OUT | GLib.IOCondition.IN | \
- GLib.IOCondition.PRI | GLib.IOCondition.HUP
- FLAG_CLOSE = GLib.IOCondition.HUP
-
-PENDING_READ = 3 # waiting read event
-PENDING_WRITE = 4 # waiting write event
-IS_CLOSED = 16 # channel closed
+ GLib.IOCondition.PRI | GLib.IOCondition.HUP
+ FLAG_CLOSE = GLib.IOCondition.HUP
+ PENDING_READ = GLib.IOCondition.IN # There is data to read.
+ PENDING_WRITE = GLib.IOCondition.OUT # Data CAN be written without
blocking.
+ IS_CLOSED = GLib.IOCondition.HUP # Hung up (connection broken)
def get_idlequeue():
"""
@@ -426,26 +428,15 @@ class IdleQueue(object):
def process(self):
"""
+ This function must be overridden by an implementation of the IdleQueue.
+
Process idlequeue. Check for any pending timeout or alarm events. Call
IdleObjects on possible and requested read, write and error events on
their file descriptors
Call this in regular intervals.
"""
- if not self.queue:
- # check for timeouts/alert also when there are no active fds
- self._check_time_events()
- return True
- try:
- waiting_descriptors = self.selector.poll(0)
- except OSError as e:
- waiting_descriptors = []
- if e.errno != errno.EINTR:
- raise
- for fd, flags in waiting_descriptors:
- self._process_events(fd, flags)
- self._check_time_events()
- return True
+ raise NotImplementedError("You need to define a process() method.")
class SelectIdleQueue(IdleQueue):
"""
@@ -474,10 +465,8 @@ class SelectIdleQueue(IdleQueue):
for fd in (bad_fds):
obj = self.queue.get(fd)
- if obj is None:
- self.unplug_idle(fd)
- return
- self.remove_timeout(fd)
+ if obj is not None:
+ self.remove_timeout(fd)
self.unplug_idle(fd)
def _init_idle(self):
=====================================
test/lib/xmpp_mocks.py
=====================================
--- a/test/lib/xmpp_mocks.py
+++ b/test/lib/xmpp_mocks.py
@@ -16,7 +16,7 @@ class IdleQueueThread(threading.Thread):
Thread for regular processing of idlequeue.
'''
def __init__(self):
- self.iq = idlequeue.IdleQueue()
+ self.iq = idlequeue.SelectIdleQueue()
self.stop = threading.Event() # Event to stop the thread main loop.
self.stop.clear()
threading.Thread.__init__(self)
View it on GitLab:
https://dev.gajim.org/gajim/python-nbxmpp/compare/e064374efac494e03973fa45f9cd2eb152a8ff03...5a37180d0f0f901e6eaecf6a8782d9a37e32c0c9
---
View it on GitLab:
https://dev.gajim.org/gajim/python-nbxmpp/compare/e064374efac494e03973fa45f9cd2eb152a8ff03...5a37180d0f0f901e6eaecf6a8782d9a37e32c0c9
You're receiving this email because of your account on dev.gajim.org.
_______________________________________________
Commits mailing list
[email protected]
https://lists.gajim.org/cgi-bin/listinfo/commits