Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
pygolang
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Carlos Ramos Carreño
pygolang
Commits
9662785b
Commit
9662785b
authored
Nov 02, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
context: Switch time.now() to cimport
parent
89381488
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
2 deletions
+3
-2
golang/_context.pyx
golang/_context.pyx
+3
-2
No files found.
golang/_context.pyx
View file @
9662785b
...
...
@@ -32,6 +32,7 @@ from golang import go as pygo, chan as pychan, select as pyselect, default as py
from
golang
import
_sync
as
_pysync
# avoid cycle: context -> sync -> context
from
golang
import
time
as
pytime
from
golang
cimport
time
from
cython
cimport
final
...
...
@@ -101,7 +102,7 @@ def with_deadline(parent, deadline): # -> ctx, cancel
return
with_cancel
(
parent
)
# timeout <= 0 -> already canceled
timeout
=
deadline
-
py
time
.
now
()
timeout
=
deadline
-
time
.
now
()
if
timeout
<=
0
:
ctx
,
cancel
=
with_cancel
(
parent
)
cancel
()
...
...
@@ -114,7 +115,7 @@ def with_deadline(parent, deadline): # -> ctx, cancel
#
# it is shorthand for with_deadline(parent, now+timeout).
def
with_timeout
(
parent
,
timeout
):
# -> ctx, cancel
return
with_deadline
(
parent
,
py
time
.
now
()
+
timeout
)
return
with_deadline
(
parent
,
time
.
now
()
+
timeout
)
# merge merges 2 contexts into 1.
#
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment