Merge "Avoid crash due to POLLIN event check"
This commit is contained in:
commit
05d2786986
@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
|
import platform
|
||||||
import pprint
|
import pprint
|
||||||
import select
|
import select
|
||||||
import six.moves
|
import six.moves
|
||||||
@ -34,6 +35,7 @@ UPDATE_ALLOWED_KEYS = ['description', 'submit-type',
|
|||||||
'content-merge', 'change-id',
|
'content-merge', 'change-id',
|
||||||
'project-state',
|
'project-state',
|
||||||
'max-object-size-limit']
|
'max-object-size-limit']
|
||||||
|
IS_LINUX = platform.system() == "Linux"
|
||||||
|
|
||||||
|
|
||||||
class GerritConnection(object):
|
class GerritConnection(object):
|
||||||
@ -158,10 +160,13 @@ class GerritWatcher(threading.Thread):
|
|||||||
ret = poll.poll()
|
ret = poll.poll()
|
||||||
for (fd, event) in ret:
|
for (fd, event) in ret:
|
||||||
if fd == stdout.channel.fileno():
|
if fd == stdout.channel.fileno():
|
||||||
if event == select.POLLIN:
|
# event is a bitmask
|
||||||
|
# On Darwin non-critical OOB messages can be received
|
||||||
|
if (IS_LINUX and event == select.POLLIN) or \
|
||||||
|
(not IS_LINUX and event & select.POLLIN):
|
||||||
self._read(stdout)
|
self._read(stdout)
|
||||||
else:
|
else:
|
||||||
raise Exception("event on ssh connection")
|
raise Exception("event %s on ssh connection" % event)
|
||||||
|
|
||||||
def _consume(self, client):
|
def _consume(self, client):
|
||||||
"""Consumes events using the given client."""
|
"""Consumes events using the given client."""
|
||||||
|
Loading…
Reference in New Issue
Block a user