[PATCH 1 of 4 V2] util: add a simple poll utility
Adrian Buehlmann
adrian at cadifra.com
Thu Jun 4 05:37:15 UTC 2015
On 2015-06-04 03:57, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david at fb.com>
> # Date 1432162805 18000
> # Wed May 20 18:00:05 2015 -0500
> # Node ID 9d7dc60dc701d327ddda449e7455e85513d5df5b
> # Parent 443d4635e630cf5603afb6ba4bfcf6a0d68cd7a6
> util: add a simple poll utility
>
> We'll use it to detect when a sshpeer have server output to be displayed.
>
> The implementation is super basic because all case support is not the focus of
> this series.
>
> diff --git a/mercurial/posix.py b/mercurial/posix.py
> --- a/mercurial/posix.py
> +++ b/mercurial/posix.py
..
> diff --git a/mercurial/windows.py b/mercurial/windows.py
> --- a/mercurial/windows.py
> +++ b/mercurial/windows.py
> @@ -369,10 +369,20 @@ def statislink(st):
>
> def statisexec(st):
> '''check whether a stat result is an executable file'''
> return False
>
> +def poll(fds):
> + """block until something happened on any filedescriptors
I think you can drop the rest of the doc string. Or perhaps instead
refer to posix module (in order to avoid comment duplication).
> +
> + This is a generic helper that will check for any activity
> + (read, write. exception). return the list of touched file.
> +
> + In unsupported case raise a NotImplementedError"""
..
> + if os.name == 'nt': # we do not support windows yet.
> + raise NotImplementedError()
> +
os.name is always 'nt' inside this module, so this can be simplified to:
raise NotImplementedError()
(Nitpick: I think the comment ("we do not support windows yet.") is
unneeded. If you want to keep it: The correct name of that OS is 'Windows')
> def readpipe(pipe):
> """Read all available data from a pipe."""
> chunks = []
> while True:
> size = win32.peekpipe(pipe)
More information about the Mercurial-devel
mailing list