pygolang:21525a8d29777be96dd4585e25dca9eb9fd8707b commitshttps://lab.nexedi.com/nexedi/pygolang/-/commits/21525a8d29777be96dd4585e25dca9eb9fd8707b2019-08-26T12:16:48+03:00https://lab.nexedi.com/nexedi/pygolang/-/commit/21525a8d29777be96dd4585e25dca9eb9fd8707bmanifest: Simplify a bit2019-08-26T12:16:48+03:00Kirill Smelkovkirr@nexedi.com
We can include *.py from top-level directories, not only under
X/testdata/, X/testprog/ ...https://lab.nexedi.com/nexedi/pygolang/-/commit/7ef58207211f12099d68db3cd33a3b19d6a83fffgolang_test: Rename test_go -> test_go_leaked2019-08-26T12:16:48+03:00Kirill Smelkovkirr@nexedi.com
This test is veriyfing only how leaked goroutines behave, not go in
general.https://lab.nexedi.com/nexedi/pygolang/-/commit/62bdb8065a0a73b3318aeb027480ee62ae5e7441golang_test: Switch test_go to pyrun2019-08-26T12:16:48+03:00Kirill Smelkovkirr@nexedi.com
test_go was doing the same what pyrun is doing + adjusting PYTHONPATH a
bit. Merge PYTHONPATH adjustment into pyrun and use pyrun uniformly.https://lab.nexedi.com/nexedi/pygolang/-/commit/88eb8fe08a94bb77045a6f9a818c9edfda8d579egolang_test: Split pyrun into -> pyrun & pyout2019-08-26T12:16:48+03:00Kirill Smelkovkirr@nexedi.com
pyrun runs command without piping output.
pyout runs command and returns its output.https://lab.nexedi.com/nexedi/pygolang/-/commit/f812faa2dd81e8896d3523597c58558618bed5fatests: Factor out pyrun from gpython_test into golang_test2019-08-26T12:16:48+03:00Kirill Smelkovkirr@nexedi.com
We'll need to use this utility in other places; golang_test is the
central place for testing utilities.https://lab.nexedi.com/nexedi/pygolang/-/commit/75169174be71e589322c50d46ab11fd8505df7e3gpython_test: Kill unused imports2019-08-26T12:16:48+03:00Kirill Smelkovkirr@nexedi.com
gpython/gpython_test.py:23: 'subprocess' imported but unused
gpython/gpython_test.py:24: 'six.PY3' imported but unusedhttps://lab.nexedi.com/nexedi/pygolang/-/commit/89a1061a74723d0e3ab1e136860643523cd4d3f1setup: Provide golang.X requirements in pygolang[X]2019-08-26T12:16:03+03:00Kirill Smelkovkirr@nexedi.com
... and everything that whole pygolang depends on in pygolang[all].
The reason we do this: currently golang.perf.benchlib needs NumPy, but
it would be not ok to depend whole pygolang on numpy. Similarly pybench
needs pytest, but it would be not ok to require pytest unconditionally.
Thus allow users to specify what they need from pygolang via extras,
like pygolang[x.perf.benchlib] or pygolang[cmd.pybench], with
pygolang[all] serving as merge point for all subpackages dependencies.
TODO in the future we'll, hopefully, also provide accumulation points,
like pygolang[x.perf] which contains everything pygolang[x.perf.*]
depends on.
Note: core functionality and gpython are provided always unconditionally.https://lab.nexedi.com/nexedi/pygolang/-/commit/02f6991f8ec718301cbec1e86d780efdc1d314aagolang: Add test for blocked select(send|recv) vs close2019-08-23T19:31:10+03:00Kirill Smelkovkirr@nexedi.com
This test passes, but the functionality was not tested before. In
particular all tests were passing even with the following hand-edits:
--- a/golang/__init__.py
+++ b/golang/__init__.py
@@ -627,7 +627,7 @@ def selected():
sel = g.which
if isinstance(sel, _SendWaiting):
if not sel.ok:
- panic("send on closed channel")
+ panic("send on closed channel ZZZ")
return sel.sel_n, None
if isinstance(sel, _RecvWaiting):
with added tests the bug is caught and reported:
def test_select():
N = 1000 # times to do repeated select/chan or select/select interactions
# sync: close vs select(send)
ch = chan()
def _():
waitBlocked(ch.send)
ch.close()
go(_)
> with panics("send on closed channel"): select((ch.send, 0))
golang_test.py:353:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <golang.golang_test.panics instance at 0x7fc1da66e5f0>, exc_type = <class 'golang._PanicError'>, exc_val = _PanicError('send on closed channel ZZZ',)
exc_tb = <traceback object at 0x7fc1dabc33b0>
def __exit__(self, exc_type, exc_val, exc_tb):
ok = self.raises.__exit__(exc_type, exc_val, exc_tb)
if not ok:
return ok
# _PanicError raised - let's check panic argument
> assert self.exc_info.value.args == (self.arg,)
E AssertionError: assert ('send on clo...channel ZZZ',) == ('send on closed channel',)
E At index 0 diff: 'send on closed channel ZZZ' != 'send on closed channel'
E Use -v to get the full diff
golang_test.py:1032: AssertionErrorhttps://lab.nexedi.com/nexedi/pygolang/-/commit/c6bb9eb338c3b48106fff4b58a71808316acc2bfgolang: Fix race in chan._tryrecv2019-08-23T19:31:10+03:00Kirill Smelkovkirr@nexedi.com
For buffered channel _tryrecv, on success, was unlocking ch._mu too
early - before accessing ch._dataq with ch._dataq.append().
Without the fix, newly added test breaks as e.g.
golang/golang_test.py::test_chan_buf_recv_vs_tryrecv_race Exception in thread Thread-3:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
self.run()
File "/usr/lib/python2.7/threading.py", line 754, in run
self.__target(*self.__args, **self.__kwargs)
File "/home/kirr/src/tools/go/pygolang-master/golang/golang_test.py", line 317, in _
assert (_, _rx) == (1, None), ('i%d' % i)
AssertionError: i30
assert (0, None) == (1, None)
At index 0 diff: 0 != 1
Full diff:
- (0, None)
? ^
+ (1, None)
? ^https://lab.nexedi.com/nexedi/pygolang/-/commit/eb8a1fef30040785fdcd18f09c8eb4928c967d11golang: Fix race in chan._trysend2019-08-23T19:31:10+03:00Kirill Smelkovkirr@nexedi.com
For buffered channel _trysend, on success, was unlocking ch._mu too
early - before accessing ch._dataq with ch._dataq.popleft().
Without the fix, newly added test breaks as e.g.
golang/golang_test.py::test_chan_buf_send_vs_tryrecv_race Exception in thread Thread-3:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
self.run()
File "/usr/lib/python2.7/threading.py", line 754, in run
self.__target(*self.__args, **self.__kwargs)
File "/home/kirr/src/tools/go/pygolang-master/golang/golang_test.py", line 256, in _
assert (_, _rx) == (1, None)
AssertionError: assert (0, 209) == (1, None)
At index 0 diff: 0 != 1
Full diff:
- (0, 209)
+ (1, None)
Exception in thread Thread-2:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
self.run()
File "/usr/lib/python2.7/threading.py", line 754, in run
self.__target(*self.__args, **self.__kwargs)
File "/home/kirr/src/tools/go/pygolang-master/golang/golang_test.py", line 243, in _
ch.send(i)
File "/home/kirr/src/tools/go/pygolang-master/golang/__init__.py", line 340, in send
ok = self._trysend(obj)
File "/home/kirr/src/tools/go/pygolang-master/golang/__init__.py", line 417, in _trysend
rx = self._dataq.popleft()
IndexError: pop from an empty dequehttps://lab.nexedi.com/nexedi/pygolang/-/commit/cb5bfdd23d13f568eaaf494bf53fe5e87e1def1bgolang: Test that buffered channel releases objects from buffer on chan GC2019-08-23T19:31:10+03:00Kirill Smelkovkirr@nexedi.com
Currently it behaves correctly, but this aspect will need to be
explicitly cared about when channel implementation moves to C. Add test
to make sure it won't regress.https://lab.nexedi.com/nexedi/pygolang/-/commit/c5810987cb3392b6d98b2d29b71025ef3cd6abf4golang: Run all select tests "more thoroughly"2019-08-23T19:31:10+03:00Kirill Smelkovkirr@nexedi.com
Starting from <a href="/nexedi/pygolang/-/commit/b51b8d5d64f020f2b0892eb0f9d2c3a4968c39e3" data-original="b51b8d5d" data-link="false" data-link-reference="false" data-project="1156" data-commit="b51b8d5d64f020f2b0892eb0f9d2c3a4968c39e3" data-reference-type="commit" data-container="body" data-placement="top" data-html="true" title="select: Run tests more thoroughly" class="gfm gfm-commit has-tooltip">b51b8d5d</a> (select: Run tests more thoroughly) we are
running select subtests in repeated mode with N=1000. However not all
select subtests were run in repeated mode - for example e.g.
"non-blocking try send: not ok" was being run only once.
-> Rework all select subtests to be run in repeated mode to increase the
probability of catching bugs.https://lab.nexedi.com/nexedi/pygolang/-/commit/fa66741271751f075493b129329d7ba42619eb83golang: tests: Use panic when testing "blocks forever"2019-08-23T19:31:08+03:00Kirill Smelkovkirr@nexedi.com
Channels implementation will soon be moved to C and will become
independent from Python runtime. This way while pygolang will still be
providing panic, hooking in and raising arbitrary Python-level exception
will become problematic. -> Rework "blocks forever" tests to rely on
just panic to prepare for that.https://lab.nexedi.com/nexedi/pygolang/-/commit/352628b5310badeeec521d523fa39339f80238f7golang: tests: Factor out retrieving len(ch._recvq) and len(ch._sendq)2019-08-23T19:29:55+03:00Kirill Smelkovkirr@nexedi.com
Chan implementation is going to be moved into C, and this way direct
access to chan internals won't be possible. C implementation will export
dedicated functions for chan tests which will be used.
Prepare for that and factor out retrieving len of chan recv/send queues
into separate functions, which will be adapted at the time of C port.https://lab.nexedi.com/nexedi/pygolang/-/commit/d98e42e3283519dbbc89e8c7f7f0dc1e5e29db61golang: Don't verify ._recvq and ._sendq of nil channel2019-08-23T19:29:55+03:00Kirill Smelkovkirr@nexedi.com
Nil channel will soon be changed to be represented by underlying NULL C
pointer and there won't be channel object for nil and correspondingly
recv/send queues won't be there. -> Prepare for that and don't check for
recvq/sendq on nil channel.https://lab.nexedi.com/nexedi/pygolang/-/commit/049ba6ff77afe27fc9eb9fc55d58074a2c222943golang: Remove outdated TODO2019-08-23T19:29:55+03:00Kirill Smelkovkirr@nexedi.com
We provide gpython since <a href="/nexedi/pygolang/-/commit/32a21d5b36579ac2488edfc675567eeb364a3e13" data-original="32a21d5b" data-link="false" data-link-reference="false" data-project="1156" data-commit="32a21d5b36579ac2488edfc675567eeb364a3e13" data-reference-type="commit" data-container="body" data-placement="top" data-html="true" title="gpython: Python interpreter with support for lightweight threads" class="gfm gfm-commit has-tooltip">32a21d5b</a> (gpython: Python interpreter with
support for lightweight threads), and golang module, since the
beginning, automatically uses gevent if it was installed via monkey
patching.https://lab.nexedi.com/nexedi/pygolang/-/commit/7f2362dd1d7f9363309ad89b8574318b0a7e71detime: Test for now2019-08-23T19:29:55+03:00Kirill Smelkovkirr@nexedi.com
This currently pass trivially (since time.now = stdtime.now), but will
be useful once we get time.now implementation into our hands and move it into Cython.https://lab.nexedi.com/nexedi/pygolang/-/commit/c3bd2c50e07308a26ca38b1ee7feb99cd2f4cc88*: Use golang.time universally2019-08-23T19:29:55+03:00Kirill Smelkovkirr@nexedi.com
After <a href="/nexedi/pygolang/-/commit/9c260fde465e48a5e5d053179ca409462a75d732" data-original="9c260fde" data-link="false" data-link-reference="false" data-project="1156" data-commit="9c260fde465e48a5e5d053179ca409462a75d732" data-reference-type="commit" data-container="body" data-placement="top" data-html="true" title="time: New package that mirrors Go's time" class="gfm gfm-commit has-tooltip">9c260fde</a> (time: New package that mirrors Go's time) we have
golang.time.now and golang.time.sleep and it makes it a more
self-dependent system if timing facility is used through golang.time
instead of outside std time module.
For now this is only a "cleanness" change, but will become important once
we start adding pyx-level nogil API to pygolang - there it will be
important to use golang.time.* for correctness.https://lab.nexedi.com/nexedi/pygolang/-/commit/78d85cdc52c8cee810fb4b89b4ca7a2bcce61978sync: threading.Event -> chan2019-08-23T19:29:55+03:00Kirill Smelkovkirr@nexedi.com
Starting from <a href="/nexedi/pygolang/-/commit/e6bea2cfdae4be96c92a383eee7ba956c498eb30" data-original="e6bea2cf" data-link="false" data-link-reference="false" data-project="1156" data-commit="e6bea2cfdae4be96c92a383eee7ba956c498eb30" data-reference-type="commit" data-container="body" data-placement="top" data-html="true" title="sync: New package that mirrors Go's sync" class="gfm gfm-commit has-tooltip">e6bea2cf</a> (sync: New package that mirrors Go's sync) there
is sync.WaitGroup and it was using threading.Event to signal that
waitgroup's counter dropped to zero. threading.Event is implemented in
Python's stdlib via threading.Condition, which in turn uses
threading.Lock and list of waiters to implement its functionality.
Which in turn is very similar to what golang.chan does internally with
semaphore and e.g. recv queue.
I noticed this while debugging sync test deadlock (see previous patch)
and suspecting bug in threading.Event for a moment. While it turned
there is no bug in threading.Event, it is better to rely on the common
functionality for similar tasks, and pygolang's channel perfectly
matches here the need to signal an event. By using our own code instead
of stdlib's threading we are likely becoming less bug-prone.
This also brings a small speedup:
(on i5@1.80GHz)
name old time/op new time/op delta
workgroup_empty 239µs ± 1% 220µs ± 1% -7.62% (p=0.000 n=10+9)
workgroup_raise 275µs ± 2% 264µs ± 2% -3.85% (p=0.000 n=10+10)https://lab.nexedi.com/nexedi/pygolang/-/commit/b8b042c5cdcc207982ae96be658230b8d46f430csync.WorkGroup: Fix deadlock thinko in tests2019-08-23T19:29:55+03:00Kirill Smelkovkirr@nexedi.com
sync.WorkGroup test was doing ctx.done() wait from under test mutex,
something like
def _(ctx, i):
with mu:
...
if i == 0:
raise RuntimeError() # to cause ctx cancel
ctx.done().recv() # i=1 -> wait till ctx is canceled
but it can be a deadlock if T(i=1) runs first and enters
ctx.done().recv() before T(i=0) is run - then T(i=0) will block forever
waiting to lock mu.
This failure was not seen so far, probably because the time to go a new
thread/goroutine is relatively high. However one of upcoming patches,
where go is made faster, revealed this problem and, without the fix,
sync.WorkGroup test was regularly deadlocking.
The problem was there from sync.WorkGroup beginning - from
<a href="/nexedi/pygolang/-/commit/9ee7ba91771c8a84be6444f50937a1185c84e12e" data-original="9ee7ba91" data-link="false" data-link-reference="false" data-project="1156" data-commit="9ee7ba91771c8a84be6444f50937a1185c84e12e" data-reference-type="commit" data-container="body" data-placement="top" data-html="true" title="sync += WorkGroup" class="gfm gfm-commit has-tooltip">9ee7ba91</a> (sync += WorkGroup).
Fix the deadlock by waiting for ctx.done() outside of mu.https://lab.nexedi.com/nexedi/pygolang/-/commit/086d4296b6e4cd2e887aef80f561841b2646912dgolang: gimport works on Py32019-08-23T19:29:55+03:00Kirill Smelkovkirr@nexedi.com
<a href="/nexedi/pygolang/-/commit/9c61f254d1985e5356d53d0564a999e654247471" data-original="9c61f254" data-link="false" data-link-reference="false" data-project="1156" data-commit="9c61f254d1985e5356d53d0564a999e654247471" data-reference-type="commit" data-container="body" data-placement="top" data-html="true" title="pygopath: Initial draft" class="gfm gfm-commit has-tooltip">9c61f254</a> (pygopath: Initial draft) has a "TODO py3 support", probably
because <a href="https://stackoverflow.com/a/67692" rel="nofollow noreferrer noopener" target="_blank">https://stackoverflow.com/a/67692</a> shows different codes for
Python2 and Python3.
However today we have tox coverage for all Python2.7, Python3.6 and
Python3.7 and everything works including gimport tests.
-> Remove the TODO.https://lab.nexedi.com/nexedi/pygolang/-/commit/7d08f07833ce95b2e536bb6872c0ce093f2e727cgolang/_gopath_test: Redo $GOPATH set/restore via fixture2019-08-23T19:29:55+03:00Kirill Smelkovkirr@nexedi.com
Currently gimport tests depend on module-level setup_module /
teardown_module, which require for gimport tests to be in separate file.
Redo the test not to depend on global module-level state and
setup/teardown. This allows e.g. to merge gimport tests into
golang_test.py if/when we want/need to.https://lab.nexedi.com/nexedi/pygolang/-/commit/3e5b5f0120333ee46079bf0173189346e38dc899golang: Test len(nilchan) and repr(nilchan)2019-08-23T19:29:37+03:00Kirill Smelkovkirr@nexedi.com
Should be in <a href="/nexedi/pygolang/-/commit/2aad64bb954d28a28171b92deba8eb3f7c72a22a" data-original="2aad64bb" data-link="false" data-link-reference="false" data-project="1156" data-commit="2aad64bb954d28a28171b92deba8eb3f7c72a22a" data-reference-type="commit" data-container="body" data-placement="top" data-html="true" title="golang: Add support for nil channel" class="gfm gfm-commit has-tooltip">2aad64bb</a> (golang: Add support for nil channel).https://lab.nexedi.com/nexedi/pygolang/-/commit/773d8fb28ca8a8e6af4730df49528ea63a5e0f1b*_test: Verify panic argument2019-07-20T21:29:13+03:00Kirill Smelkovkirr@nexedi.com
In tests in places where the code checks that something panics, verify
not only that _PanicError is raised, but also what was the argument
passed to panic.
This makes sure that tested code panics in expected place, not just
panics "somewhere".
To keep signal/noise ratio high introduce `panics` which is similar to
`pytest.raises` and asserts that wrapped code panics with expected
argument.https://lab.nexedi.com/nexedi/pygolang/-/commit/f858ed70da79c9e7c8cbab1ae89e64c3fcca036dtox: Don't duplicate setup.py on which for-tests dependencies we need2019-07-08T13:09:49+03:00Kirill Smelkovkirr@nexedi.com
-> Use .[test] to refer to them.
<a href="https://stackoverflow.com/a/41398850/9456786" rel="nofollow noreferrer noopener" target="_blank">https://stackoverflow.com/a/41398850/9456786</a>https://lab.nexedi.com/nexedi/pygolang/-/commit/79aab7dfe5d4b2c093a398dc7427b26c4806e93dsync.WorkGroup: Propagate all exception types, not only those derived from Ex...2019-06-26T20:16:47+03:00Kirill Smelkovkirr@nexedi.com
A problem was hit with pytest.fail with raises Failed exception not
being propagated to .wait. As it turned out it was not propagated
because pytest's Failed derives from BaseException, not Exception, and
we were catching only Exception and its children.
Rework the code to propagate all exception types from workers.
Performance change is with noise (it is either a bit faster for one set
of runs, or a bit slower for another set of runs).https://lab.nexedi.com/nexedi/pygolang/-/commit/94c6160b3dce12bcb81e7e0f0cb628fd26c637cesync.Workgroup: Don't use @func at runtime2019-06-26T14:50:55+03:00Kirill Smelkovkirr@nexedi.com
It is true for any decorator, that it makes things faster if
def+decorator is used globally instead of at runtime, but for @func it
is especially true since @func, using decorator.decorate, has relatively
high overhead if it is used not only once at program startup, but
instead every time something is run.
In particular moving @func out of WorkGroup.go() make things
considerably faster:
name old time/op new time/op delta
workgroup_empty 195µs ± 0% 113µs ± 1% -41.91% (p=0.008 n=5+5)
workgroup_raise 221µs ± 1% 137µs ± 1% -38.29% (p=0.008 n=5+5)
See
<a href="https://lab.nexedi.com/kirr/misc/raw/009c4fee/pygolang/prof_workgroup_empty.svg">https://lab.nexedi.com/kirr/misc/raw/009c4fee/pygolang/prof_workgroup_empty.svg</a>
for bench_workgroup_empty profile, where it is seen that
decorator.decorate was using ~ half of the whole WorkGroup.go() time.https://lab.nexedi.com/nexedi/pygolang/-/commit/3c55ca597351dcd255e6ecc03276b4e4cb8fce66golang: Add benchmarks for chan, select, @func and defer2019-06-26T13:20:32+03:00Kirill Smelkovkirr@nexedi.com
Start adding benchmarks to pygolang.
Measure how much sync chan send/recv take and how much select takes for
synchronous channels. Also measure how much overhead @func adds at both
def and call times, and the overhead of defer compared to try/finally.
For std (non-gevent'ed) Python2.7 we are currently at:
name time/op
go 91.6µs ± 1%
chan 13.7µs ± 3%
select 30.1µs ± 4%
def 55.0ns ± 0%
func_def 43.6µs ± 0%
call 63.0ns ± 0%
func_call 1.06µs ± 0%
try_finally 136ns ± 1%
defer 2.33µs ± 0%https://lab.nexedi.com/nexedi/pygolang/-/commit/c3ea8f515d7e99dc0462ace4f338df98fc98be4cgolang: test_method -> test_func2019-06-26T12:17:05+03:00Kirill Smelkovkirr@nexedi.com
@method(cls) was deprecated and removed in favour of @func(cls) in
<a href="/nexedi/pygolang/-/commit/942ee9009d2e0a5d5cc174e72243591eee86ba55" data-original="942ee9009d" data-link="false" data-link-reference="false" data-project="1156" data-commit="942ee9009d2e0a5d5cc174e72243591eee86ba55" data-reference-type="commit" data-container="body" data-placement="top" data-html="true" title="golang: Deprecate @method(cls) in favour of @func(cls)" class="gfm gfm-commit has-tooltip">942ee900</a> (golang: Deprecate @method(cls) in favour of @func(cls)) and
<a href="/nexedi/pygolang/-/commit/262f89861b826bb26ece1627299c39f8cb6dadb4" data-original="262f89861b" data-link="false" data-link-reference="false" data-project="1156" data-commit="262f89861b826bb26ece1627299c39f8cb6dadb4" data-reference-type="commit" data-container="body" data-placement="top" data-html="true" title="golang: Kill @method" class="gfm gfm-commit has-tooltip">262f8986</a> (golang: Kill @method). The test name was overlooked.https://lab.nexedi.com/nexedi/pygolang/-/commit/924a808cbb008c2130b11f320fc3fc61bb4c6419golang: Fix `@func(cls) def name` not to override `name` in calling context2019-06-21T10:50:11+03:00Kirill Smelkovkirr@nexedi.com
With @func being a decorator, the following
@func(cls)
def name():
...
is always processed by python as
name = func(cls)(def name(): ...)
Before this patch it was leading to name being overridden with None:
def f():
print 'hello'
class C:
pass
@func(C)
def f(c):
print 'C.f', c
f()
Traceback (most recent call last):
File "<console>", line 1, in <module>
TypeError: 'NoneType' object is not callable
We can fix it by returning from `func(cls)(def name(): ...)` the
original `name` object from the calling context.
Unfortunately if `name` was not previously set I did not find a way(*) to
avoid polluting the calling namespace where it is set to what @func(cls)
returns (None) by the hardcoded way how python processes decorators:
In [2]: c = """
...: @fff
...: def ccc():
...: return 1
...: """
In [3]: cc = compile(c, "file", "exec")
In [4]: dis(cc)
2 0 LOAD_NAME 0 (fff)
3 LOAD_CONST 0 (<code object ccc at 0x7fafe58d0130, file "file", line 2>)
6 MAKE_FUNCTION 0
9 CALL_FUNCTION 1
12 STORE_NAME 1 (ccc) <-- NOTE means: ccc = what fff() call returns
15 LOAD_CONST 1 (None)
18 RETURN_VALUE
At least with no overriding taking place the situation is better now.
NOTE: it is only @func(cls) which potentially pollutes calling
namespace. Just @func (without class) is always clean because by
definition it works as a regular decorator.
(*) there is a very low-level and potentially fragile way to disable
STORE_NAME after CALL_FUNCTION by dynamically patching caller's bytecode
at runtime and replacing STORE_NAME with POP_TOP + NOP...https://lab.nexedi.com/nexedi/pygolang/-/commit/08ec795088e6653eb073cf422559ffb5d38fde9aRevert "tox -= Python3.6"2019-05-24T10:08:29+03:00Kirill Smelkovkirr@nexedi.com
This reverts commit <a href="/nexedi/pygolang/-/commit/469f21a9527becce8dc12134ad08d16cde7f28cd" data-original="469f21a9527becce8dc12134ad08d16cde7f28cd" data-link="false" data-link-reference="false" data-project="1156" data-commit="469f21a9527becce8dc12134ad08d16cde7f28cd" data-reference-type="commit" data-container="body" data-placement="top" data-html="true" title="tox -= Python3.6" class="gfm gfm-commit has-tooltip">469f21a9</a>.
Even though Debian stopped shipping Python3.6 I'm now building it myself
to have test coverage for two latest Python releases.https://lab.nexedi.com/nexedi/pygolang/-/commit/d3bfb1bfe71340dbf32d7b75e52820493cf1f401pygolang v0.0.22019-05-16T20:27:45+03:00Kirill Smelkovkirr@nexedi.comhttps://lab.nexedi.com/nexedi/pygolang/-/commit/b2450310cd3d9b3d4247090a689a7a60ebfc15b5context: Add support for deadlines2019-05-16T20:12:49+03:00Kirill Smelkovkirr@nexedi.com
Implement deadlines / timeouts using timers added recently in <a href="/kirr/pygolang/-/commit/9c260fde465e48a5e5d053179ca409462a75d732" data-original="9c260fde" data-link="false" data-link-reference="false" data-project="1158" data-commit="9c260fde465e48a5e5d053179ca409462a75d732" data-reference-type="commit" data-container="body" data-placement="top" data-html="true" title="time: New package that mirrors Go's time" class="gfm gfm-commit has-tooltip">9c260fde</a>
(time: New package that mirrors Go's time).https://lab.nexedi.com/nexedi/pygolang/-/commit/27f91b78019f4ee1632868688679d886a964490econtext: tests: Factor out common bits from test_context2019-05-16T19:31:11+03:00Kirill Smelkovkirr@nexedi.com
In the next patch we'll be adding deadlines support with another test.
Move common infrastructure that will be used in all context tests to be
test-module global.https://lab.nexedi.com/nexedi/pygolang/-/commit/e5687f2f4ac12ab0b3b8e03f41160c7c81687dd1context: Don't hardcode that contexts are always done with canceled error2019-05-16T19:25:27+03:00Kirill Smelkovkirr@nexedi.com
We'll need to mark contexts that miss their deadline with
deadlineExceeded error in a follow-up patch.
In this patch: transform _BaseCtx._cancel to accept an error with which
a context has to be canceled, but for now always use canceled in places
where _cancel is called.https://lab.nexedi.com/nexedi/pygolang/-/commit/58ba1765a65e86db84f45cc61a3cad475b6e0256context: Note that a context has to be explicitly canceled to release resources2019-05-16T19:25:27+03:00Kirill Smelkovkirr@nexedi.com
Same story as in Go, but we were lacking documentation notice about this.https://lab.nexedi.com/nexedi/pygolang/-/commit/9c260fde465e48a5e5d053179ca409462a75d732time: New package that mirrors Go's time2019-05-16T18:58:19+03:00Kirill Smelkovkirr@nexedi.com
Add time.Timer, time.Ticker and convenience functions time.tick,
time.after and time.after_func. These will be used in context to support
deadlines and timeouts.
While at time topic, also provide sleep and now from golang.time, so
that there is no need to import both golang.time and stdlib's time in a
file.
Provide time constants in the module as they are useful to have and
mirror constants provided by Go's time.
Note: timers implementation is very suboptimal for now.https://lab.nexedi.com/nexedi/pygolang/-/commit/6e3b3ff47b1c099a7e5fcf8c2a43e05f77dd441fgolang: Don't keep test programs inside golang/ dir2019-05-16T18:57:01+03:00Kirill Smelkovkirr@nexedi.com
Python adds dirname of run program to sys.path . This way when
golang_test_goleaked.py runs it can import modules located under golang/
just by their name. Until now this was not noticed, but in the next
patch we are going to add golang.time module and if test program is run
with golang/ in sys.path just plain `import time` won't import time from
stdlib and instead import time from golang/ .
Such behaviour can be mitigated by doing `from __future__ import
absolute_import` and we do that, including in golang_test_goleaked.py
(see <a href="/kirr/pygolang/-/commit/81dfefa059d4a1f67293b3d3c1aa34c0b0b6b1d2" data-original="81dfefa0" data-link="false" data-link-reference="false" data-project="1158" data-commit="81dfefa059d4a1f67293b3d3c1aa34c0b0b6b1d2" data-reference-type="commit" data-container="body" data-placement="top" data-html="true" title="*: __future__ += absolute_imports; Use unified __future__ everywhere" class="gfm gfm-commit has-tooltip">81dfefa0</a> "*: __future__ += absolute_imports; Use unified __future__
everywhere"). However that does not prevent modules - even modules from
stdlib - who are doing `import time` and not doing future
absolute_import to import golang's time instead of stdlib. For example
on PyPy2 threading imports time and then the test breaks:
Traceback (most recent call last):
File "/home/kirr/src/tools/go/pygolang/.tox/pypy-thread/site-packages/golang/golang_test_goleaked.py", line 24, in <module>
from golang import go, chan
File "/home/kirr/src/tools/go/pygolang/.tox/pypy-thread/site-packages/golang/__init__.py", line 38, in <module>
import inspect, threading, collections, random, sys
File "/usr/lib/pypy/lib-python/2.7/threading.py", line 15, in <module>
from time import time as _time, sleep as _sleep
File "/home/kirr/src/tools/go/pygolang/.tox/pypy-thread/site-packages/golang/time.py", line 30, in <module>
from golang import go, chan, select, default, nilchan, panic
ImportError: cannot import name 'go'
-> Move the test program into a directory different from golang/ to
avoid this trap.https://lab.nexedi.com/nexedi/pygolang/-/commit/81dfefa059d4a1f67293b3d3c1aa34c0b0b6b1d2*: __future__ += absolute_imports; Use unified __future__ everywhere2019-05-14T19:18:39+03:00Kirill Smelkovkirr@nexedi.com
- we are going to introduce golang.time, and from inside there without
`from __future__ import absolute_imports` it won't be possible to import
needed stdlib's time.
- we were already doing `from __future__ import print_function`, but
only in some files.
-> It makes sense to apply updated __future__ usage uniformly.https://lab.nexedi.com/nexedi/pygolang/-/commit/1172e39fdb9d539d76654ee963534b77d7479f8dfixup! pygolang v0.0.12019-05-10T07:13:55+03:00Kirill Smelkovkirr@nexedi.com
- correct CHANGELOG title levels: since readme uses "----" for the
first level and "~~~~" for the second level, "====" was interpreted as
the third title level and "Pygolang change history" became
sub-sub-section of "Additional packages and utilities" with section
for each version conversely becoming first level. It was not very
noticeable until <a href="/nexedi/pygolang/-/commit/0c5f9d06da60d6a019d9b66a2d4563fa930d8102" data-original="0c5f9d06" data-link="false" data-link-reference="false" data-project="1156" data-commit="0c5f9d06da60d6a019d9b66a2d4563fa930d8102" data-reference-type="commit" data-container="body" data-placement="top" data-html="true" title='readme: Push "Additional packages and utilities" into its own section' class="gfm gfm-commit has-tooltip">0c5f9d06</a> (readme: Push "Additional packages and
utilities" into its own section) started to use "~~~~".
-> Rework CHANGELOG titling to align with the one in README.
- fix minor markup bits in README.