Commit Graph

9 Commits

Author SHA1 Message Date
Jun Wu
584656dff3 codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).

Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.

Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.

An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.

As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.

Reviewed By: wez, phillco, simpkins, pkaush, singhsrb

Differential Revision: D8173629

fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-25 22:17:29 -07:00
Gregory Szorc
34a7acd6d7 wireproto: overhaul iterating batcher code (API)
The remote batching code is difficult to read. Let's improve it.

As part of the refactor, the future returned by method calls on
batchiter() instances is now populated. However, you still need to
consume the results() generator for the future to be set.  But at
least now we can stuff the future somewhere and not have to worry
about aligning method call order with result order since you can
use a future to hold the result.

Also as part of the change, we now verify that @batchable generators
yield exactly 2 values. In other words, we enforce their API.

The non-iter batcher has been unused since 3bcb9f9a4a63. And to my
surprise we had no explicit unit test coverage of it! test-batching.py
has been overhauled to use the iterating batcher.

Since the iterating batcher doesn't allow non-batchable method
calls nor local calls, tests have been updated to reflect reality.
The iterating batcher has been used for multiple releases apparently
without major issue. So this shouldn't cause alarm.

.. api::

   @peer.batchable functions must now yield exactly 2 values

Differential Revision: https://phab.mercurial-scm.org/D319
2017-08-09 23:29:30 -07:00
Gregory Szorc
014510187c wireproto: remove support for local results in @batchable (API)
@peer.batchable decorated generator functions have two forms:

    yield value, None

and

    yield args, future
    yield value

These forms have been present since the decorator was introduced.

There are currently no in-repo consumers of the first form. So this
commit removes support for it.

Note that remoteiterbatcher.submit() asserts the 2nd form. And
3bcb9f9a4a63 removed the last user of remotebatcher, forcing everyone
to remoteiterbatcher. So anything relying on this in the wild would
have been broken since 3bcb9f9a4a63.

.. api::

   @peer.batchable can no longer emit local values

Differential Revision: https://phab.mercurial-scm.org/D318
2017-08-09 22:52:05 -07:00
Yuya Nishihara
b6fd0db11c test-batching: stop direct symbol import of mercurial modules
Silences future errors reported by import-checker.py.
2016-04-05 23:10:13 +09:00
Robert Stanca
e8fffac232 py3: use print_function in test-batching.py 2016-04-03 06:10:52 +03:00
Robert Stanca
7210c10a6d py3: use absolute_import in test-batching.py 2016-04-03 06:05:43 +03:00
Augie Fackler
6a6926de03 batching: migrate basic noop batching into peer.peer
"Real" batching only makes sense for wirepeers, but it greatly
simplifies the clients of peer instances if they can be ignorant to
actual batching capabilities of that peer. By moving the
not-really-batched batching code into peer.peer, all peer instances
now work with the batching API, thus simplifying users.

This leaves a couple of name forwards in wirepeer.py. Originally I had
planned to clean those up, but it kind of unclarifies other bits of
code that want to use batching, so I think it makes sense for the
names to stay exposed by wireproto. Specifically, almost nothing is
currently aware of peer (see largefiles.proto for an example), so
making them be aware of the peer module *and* the wireproto module
seems like some abstraction leakage. I *think* the right long-term fix
would actually be to make wireproto an implementation detail that
clients wouldn't need to know about, but I don't really know what that
would entail at the moment.

As far as I'm aware, no clients of batching in third-party extensions
will need updating, which is nice icing.
2015-08-05 14:51:34 -04:00
Thomas Arendsen Hein
692a53d202 classes: fix class style problems found by 06e968819ac9
This makes test-wireprotocol.py work on Python 2.4
2011-06-29 15:00:00 +02:00
Peter Arrenbrecht
9870a43596 wireproto: add basic command batching infrastructure
Note that localbatch will not be used until we actually have a localpeer to
use it with.
2011-06-14 22:51:26 +02:00