view .arcconfig @ 36525:3158052720ae

util: enable observing of util.bufferedinputpipe Our file object proxy is useful. But it doesn't capture all I/O. The "os" module offers low-level interfaces to various system calls. For example, os.read() exposes read(2) to read from a file descriptor. bufferedinputpipe is special in a few ways. First, it acts as a proxy of sorts around our [potentially proxied] file object. In addition, it uses os.read() to satisfy all I/O. This means that our observer doesn't see notifications for reads on this type. This is preventing us from properly instrumenting reads on ssh peers. This commit teaches bufferedinputpipe to be aware of our observed file objects. We do this by introducing a class variation that notifies our observer of os.read() events. Since read() and readline() bypass os.read(), we also teach this instance to notify the observer for buffered variations of these reads as well. We don't report them as actual read() and readline() calls because these methods are never called on the actual file object but rather a buffered version of it. We introduce bufferedinputpipe.__new__ to swap in the new class if the passed file object is a fileobjectproxy. This makes hooking up the observer automatic. And it is a zero cost abstraction for I/O operations on non-proxied file objects. Differential Revision: https://phab.mercurial-scm.org/D2404
author Gregory Szorc <gregory.szorc@gmail.com>
date Sat, 24 Feb 2018 12:24:03 -0800
parents b2c27d84f05c
children ff396501e841
line wrap: on
line source

{
    "conduit_uri": "https://phab.mercurial-scm.org/api",
    "repository.callsign": "HG",
    "arc.land.onto.default": "@",
    "base": "hg:.^"
}