- 26 Jan, 2022 2 commits
-
-
Kirill Smelkov authored
Provide os/signal package that can be used to setup signal delivery to nogil channels. This way for user code signal handling becomes regular handling of a signalling channel instead of being something special or limited to only-main python thread. The rationale for why we need it is explained below: There are several problems with regular python's stdlib signal module: 1. Python2 does not call signal handler from under blocked lock.acquire. This means that if the main thread is blocked waiting on a semaphore, signal delivery will be delayed indefinitely, similarly to e.g. problem described in nxdtest!14 (comment 147527) where raising KeyboardInterrupt is delayed after SIGINT for many, potentially unbounded, seconds until ~semaphore wait finishes. Note that Python3 does not have this problem wrt stdlib locks and semaphores, but read below for the next point. 2. all pygolang communication operations (channels send/recv, sync.Mutex, sync.RWMutex, sync.Sema, sync.WaitGroup, sync.WorkGroup, ...) run with GIL released, but if blocked do not handle EINTR and do not schedule python signal handler to run (on main thread). Even if we could theoretically adjust this behaviour of pygolang at python level to match Python3, there are also C++ and pyx/nogil worlds. And we want gil and nogil worlds to interoperate (see https://pypi.org/project/pygolang/#cython-nogil-api), so that e.g. if completely nogil code happens to run on the main thread, signal handling is still possible, even if that signal handling was setup at python level. With signals delivered to nogil channels both nogil world and python world can setup signal handlers and to be notified of them irregardles of whether main python thread is currently blocked in nogil wait or not. /reviewed-on !17
-
Kirill Smelkov authored
Provide C++ package "os" with File, Pipe, etc similarly to what is provided on Go side. The package works through IO methods provided by runtimes. We need IO facility because os/signal package will need to use pipe in cooperative IO mode in its receiving-loop goroutine. os.h and os.cpp are based on drafts from wendelin.core: https://lab.nexedi.com/nexedi/wendelin.core/blob/wendelin.core-2.0.alpha1-18-g38dde766/wcfs/client/wcfs_misc.h https://lab.nexedi.com/nexedi/wendelin.core/blob/wendelin.core-2.0.alpha1-18-g38dde766/wcfs/client/wcfs_misc.cpp /reviewed-on nexedi/pygolang!17
-
- 04 Feb, 2020 1 commit
-
-
Kirill Smelkov authored
-
- 14 May, 2019 1 commit
-
-
Kirill Smelkov authored
- 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.
-
- 13 Dec, 2018 1 commit
-
-
Kirill Smelkov authored
Move quote implementation from gcompat to strconv. Make quote work on both unicode|bytes string input and produce the same output type. Preserve qq (still remaining in gcompat) to always produce str, since that is used in prints.
-
- 02 Jul, 2018 1 commit
-
-
Kirill Smelkov authored
This patch made its first step as a way to teach qq to also work on python3. However the differences in str / unicode and escapes in between py2 / py3 quickly popped out and then it became easier to just handle whole escaping logic myself. The implementation is based on kirr/go123@c0bbd06e and byproduct of manual handling is that now we don't escape printable UTF-8 characters.
-
- 20 Jun, 2018 1 commit
-
-
Kirill Smelkov authored
Not only we can import modules by full path, but now we can also spawn threads/coroutines and exchange data in between them with the same primitives and semantic as in Go. The bulk of new functionality is copied from here: kirr/go123@9e1aa6ab Original commit description follows: """ golang: New _Python_ package to provide Go-like features to Python language - `go` spawns lightweight thread. - `chan` and `select` provide channels with Go semantic. - `method` allows to define methods separate from class. - `gimport` allows to import python modules by full path in a Go workspace. The focus of first draft was on usage interface and on correctness, not speed. In particular select should be fully working. If there is a chance I will maybe try to followup with gevent-based implementation in the future. Hide whitespace changes """
-