Skip to content

Python 3 on macOS/BSDs: Clush and library fails with no timeout #353

@volans-

Description

@volans-

I wanted to test the latest release to start migrating my tool to Python 3 (thanks a lot for adding Py3 support!) and found that both clush and ClusterShell as a library fails on macOS (and other BSDs) when not setting a timeout, with ERROR: [Errno 22] Invalid argument.

After digging a bit I discovered that:

  • in Python 3 the Engine.Factory.PreferredEngine factory returns an EnginePoll on macOS, while on Python 2 it was returning an EngineSelect because poll() was not supported.
  • when polling for events in Engine.Poll.EnginePoll.runloop(), the timeout passed to the poll.poll() method is timeo * 1000.0 + 1.0, and when the timeout is not specified, timeo = -1, hence the passed timeout is -999.0.
  • Python passes the timeout parameter of select.poll.poll([timeout]) basically as-is down to the poll() system call
  • On macOS and other BSDs the poll() system call throws an error on arbitrary negative values. Only non-negative integers and -1 (or the value of INFTIM if defined) are accepted.

I've already opened an issue to Python [1] and sent a PR to hopefully fix it [2], but I'll follow up with a PR to ClusterShell too to workaround this issue passing directly -1 to the poll() method.

[1] https://bugs.python.org/issue31334
[2] python/cpython/pull/3277

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions