St2: Pinned eventlet version has outstanding bugs

Created on 29 Jan 2018  路  3Comments  路  Source: StackStorm/st2

pinned version 0.17 of eventlet has outstanding bugs on it's monkey patching of the ssl module.

e.g.
https://github.com/eventlet/eventlet/issues/371

# Note: 0.20.0 removed select.poll() on which some of our code and libraries we
# depend on rely

@Kami committed this reversion in https://github.com/StackStorm/st2/commit/1ec43d294e6770e56ec8f9990c805cb9dffe98c5

What was the specific issue?

medium

Most helpful comment

Hey guys, eventlet here.

I just want to make things clear. Hopefully help, though I couldn't find any import select in st2 code to submit a patch.

Eventlet provides coroutine-friendly versions of stdlib and few other packages under eventlet.green. Green select used to have poll just imported from stdlib, not coroutine-friendly, means eventlet.green.select.poll.poll().poll() will block everything. Which is clearly not "green", so it was removed with best intentions.

You can still have poll by using: poll = eventlet.patcher.original('select').poll but remember, it will block every other greenthread, like unpatched time.sleep or file IO backed by dying HDD. patcher.original returns same module object as import in vanilla Python stdlib without eventlet.

With that please try to offload poll it to thread pool, using eventlet.tpool.Proxy(pollobj) or eventlet.tpool.execute(pollobj.poll).

If threadpool doesn't work, your next best solution running poll with small timeout interleaved by eventlet.sleep() to give other greenthreads chance to run, like so

-from select import poll
+poll = eventlet.patcher.original('select').poll
pollobj = poll.poll()
...
- pollobj.poll()
+ while not pollobj.poll(timeout=0.02):  # mean 10ms, max 20ms lag on all other operations
    eventlet.sleep()

Fly safe.

All 3 comments

@tonybaloney this comment seems to be the relevant one (at the time anyway) https://github.com/StackStorm/st2/pull/3538#issuecomment-312282785

Hey guys, eventlet here.

I just want to make things clear. Hopefully help, though I couldn't find any import select in st2 code to submit a patch.

Eventlet provides coroutine-friendly versions of stdlib and few other packages under eventlet.green. Green select used to have poll just imported from stdlib, not coroutine-friendly, means eventlet.green.select.poll.poll().poll() will block everything. Which is clearly not "green", so it was removed with best intentions.

You can still have poll by using: poll = eventlet.patcher.original('select').poll but remember, it will block every other greenthread, like unpatched time.sleep or file IO backed by dying HDD. patcher.original returns same module object as import in vanilla Python stdlib without eventlet.

With that please try to offload poll it to thread pool, using eventlet.tpool.Proxy(pollobj) or eventlet.tpool.execute(pollobj.poll).

If threadpool doesn't work, your next best solution running poll with small timeout interleaved by eventlet.sleep() to give other greenthreads chance to run, like so

-from select import poll
+poll = eventlet.patcher.original('select').poll
pollobj = poll.poll()
...
- pollobj.poll()
+ while not pollobj.poll(timeout=0.02):  # mean 10ms, max 20ms lag on all other operations
    eventlet.sleep()

Fly safe.

@temoto Thanks for a heads up - will look into it next week.

The main problem was that we don't directly use the removed functionality ourselves, but it's a 3rd party library, so I need to figure out some work around.

The good thing is that in the context we use that library (inside an isolated and short lived subprocess) blocking is not a big deal so maybe I will just try that.

Was this page helpful?
0 / 5 - 0 ratings