Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
Pyston
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
Pyston
Commits
9b30997a
Commit
9b30997a
authored
Mar 02, 2016
by
Marius Wachtler
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
call threading._after_fork and threading._shutdown, return real thread id
parent
75bd1059
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
53 additions
and
12 deletions
+53
-12
from_cpython/Include/abstract.h
from_cpython/Include/abstract.h
+2
-2
src/capi/abstract.cpp
src/capi/abstract.cpp
+2
-2
src/capi/types.h
src/capi/types.h
+4
-1
src/core/threading.cpp
src/core/threading.cpp
+40
-1
src/runtime/builtin_modules/builtins.cpp
src/runtime/builtin_modules/builtins.cpp
+1
-1
src/runtime/builtin_modules/sys.cpp
src/runtime/builtin_modules/sys.cpp
+1
-4
src/runtime/builtin_modules/thread.cpp
src/runtime/builtin_modules/thread.cpp
+1
-1
test/tests/compile_eval.py
test/tests/compile_eval.py
+1
-0
test/tests/sys_test.py
test/tests/sys_test.py
+1
-0
No files found.
from_cpython/Include/abstract.h
View file @
9b30997a
...
...
@@ -1359,7 +1359,7 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
*/
#define PyMapping_Items(O) PyObject_CallMethod(O,"items",NULL)
PyAPI_FUNC
(
PyObject
*
)
PyMapping_GetItemString
(
PyObject
*
o
,
char
*
key
)
PYSTON_NOEXCEPT
;
PyAPI_FUNC
(
PyObject
*
)
PyMapping_GetItemString
(
PyObject
*
o
,
c
onst
c
har
*
key
)
PYSTON_NOEXCEPT
;
/*
Return element of o corresponding to the object, key, or NULL
...
...
@@ -1367,7 +1367,7 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
o[key].
*/
PyAPI_FUNC
(
int
)
PyMapping_SetItemString
(
PyObject
*
o
,
char
*
key
,
PyAPI_FUNC
(
int
)
PyMapping_SetItemString
(
PyObject
*
o
,
c
onst
c
har
*
key
,
PyObject
*
value
)
PYSTON_NOEXCEPT
;
/*
...
...
src/capi/abstract.cpp
View file @
9b30997a
...
...
@@ -1804,7 +1804,7 @@ extern "C" int PyMapping_HasKey(PyObject* o, PyObject* key) noexcept {
return
0
;
}
extern
"C"
PyObject
*
PyMapping_GetItemString
(
PyObject
*
o
,
char
*
key
)
noexcept
{
extern
"C"
PyObject
*
PyMapping_GetItemString
(
PyObject
*
o
,
c
onst
c
har
*
key
)
noexcept
{
PyObject
*
okey
,
*
r
;
if
(
key
==
NULL
)
...
...
@@ -1818,7 +1818,7 @@ extern "C" PyObject* PyMapping_GetItemString(PyObject* o, char* key) noexcept {
return
r
;
}
extern
"C"
int
PyMapping_SetItemString
(
PyObject
*
o
,
char
*
key
,
PyObject
*
value
)
noexcept
{
extern
"C"
int
PyMapping_SetItemString
(
PyObject
*
o
,
c
onst
c
har
*
key
,
PyObject
*
value
)
noexcept
{
PyObject
*
okey
;
int
r
;
...
...
src/capi/types.h
View file @
9b30997a
...
...
@@ -41,7 +41,10 @@ public:
static
BoxedString
*
__repr__
(
BoxedCApiFunction
*
self
)
{
assert
(
self
->
cls
==
capifunc_cls
);
return
boxString
(
self
->
method_def
->
ml_name
);
if
(
self
->
passthrough
==
NULL
)
return
(
BoxedString
*
)
PyString_FromFormat
(
"<built-in function %s>"
,
self
->
method_def
->
ml_name
);
return
(
BoxedString
*
)
PyString_FromFormat
(
"<built-in method %s of %s object at %p>"
,
self
->
method_def
->
ml_name
,
self
->
passthrough
->
cls
->
tp_name
,
self
->
passthrough
);
}
static
Box
*
__call__
(
BoxedCApiFunction
*
self
,
BoxedTuple
*
varargs
,
BoxedDict
*
kwargs
);
...
...
src/core/threading.cpp
View file @
9b30997a
...
...
@@ -522,11 +522,34 @@ void registerMainThread() {
assert
(
!
PyErr_Occurred
());
}
/* Wait until threading._shutdown completes, provided
the threading module was imported in the first place.
The shutdown routine will wait until all non-daemon
"threading" threads have completed. */
static
void
wait_for_thread_shutdown
(
void
)
noexcept
{
#ifdef WITH_THREAD
PyObject
*
result
;
PyThreadState
*
tstate
=
PyThreadState_GET
();
PyObject
*
threading
=
PyMapping_GetItemString
(
getSysModulesDict
(),
"threading"
);
if
(
threading
==
NULL
)
{
/* threading not imported */
PyErr_Clear
();
return
;
}
result
=
PyObject_CallMethod
(
threading
,
"_shutdown"
,
""
);
if
(
result
==
NULL
)
PyErr_WriteUnraisable
(
threading
);
else
Py_DECREF
(
result
);
Py_DECREF
(
threading
);
#endif
}
void
finishMainThread
()
{
assert
(
current_internal_thread_state
);
current_internal_thread_state
->
assertNoGenerators
();
// TODO maybe this is the place to wait for non-daemon threads?
wait_for_thread_shutdown
();
}
bool
isMainThread
()
{
...
...
@@ -601,6 +624,22 @@ extern "C" void PyEval_ReInitThreads() noexcept {
threads_waiting_on_gil
=
0
;
PerThreadSetBase
::
runAllForkHandlers
();
/* Update the threading module with the new state.
*/
Box
*
threading
=
PyMapping_GetItemString
(
getSysModulesDict
(),
"threading"
);
if
(
threading
==
NULL
)
{
/* threading not imported */
PyErr_Clear
();
return
;
}
Box
*
result
=
PyObject_CallMethod
(
threading
,
"_after_fork"
,
NULL
);
if
(
result
==
NULL
)
PyErr_WriteUnraisable
(
threading
);
else
Py_DECREF
(
result
);
Py_DECREF
(
threading
);
}
void
acquireGLWrite
()
{
...
...
src/runtime/builtin_modules/builtins.cpp
View file @
9b30997a
...
...
@@ -2540,7 +2540,7 @@ void setupBuiltins() {
{
"reload"
,
builtin_reload
,
METH_O
,
reload_doc
},
};
for
(
auto
&
md
:
builtin_methods
)
{
builtins_module
->
giveAttr
(
md
.
ml_name
,
new
BoxedCApiFunction
(
&
md
,
builtins_module
,
boxString
(
"__builtin__"
)));
builtins_module
->
giveAttr
(
md
.
ml_name
,
new
BoxedCApiFunction
(
&
md
,
NULL
,
boxString
(
"__builtin__"
)));
}
}
}
src/runtime/builtin_modules/sys.cpp
View file @
9b30997a
...
...
@@ -67,9 +67,6 @@ Box* sysExcClear() {
static
Box
*
sysExit
(
Box
*
arg
)
{
assert
(
arg
);
Box
*
exc
=
runtimeCall
(
SystemExit
,
ArgPassSpec
(
1
),
arg
,
NULL
,
NULL
,
NULL
,
NULL
);
// TODO this should be handled by the SystemExit constructor
exc
->
giveAttr
(
"code"
,
arg
);
raiseExc
(
exc
);
}
...
...
@@ -728,7 +725,7 @@ void setupSys() {
sys_flags_cls
->
freeze
();
for
(
auto
&
md
:
sys_methods
)
{
sys_module
->
giveAttr
(
md
.
ml_name
,
new
BoxedCApiFunction
(
&
md
,
sys_module
,
boxString
(
"sys"
)));
sys_module
->
giveAttr
(
md
.
ml_name
,
new
BoxedCApiFunction
(
&
md
,
NULL
,
boxString
(
"sys"
)));
}
sys_module
->
giveAttr
(
"__displayhook__"
,
sys_module
->
getattr
(
internStringMortal
(
"displayhook"
)));
...
...
src/runtime/builtin_modules/thread.cpp
View file @
9b30997a
...
...
@@ -90,7 +90,7 @@ static void* thread_start(Box* target, Box* varargs, Box* kwargs) {
// TODO this should take kwargs, which defaults to empty
Box
*
startNewThread
(
Box
*
target
,
Box
*
args
,
Box
*
kw
)
{
intptr_t
thread_id
=
start_thread
(
&
thread_start
,
target
,
args
,
kw
);
return
boxInt
(
thread_id
^
0x12345678901L
);
return
boxInt
(
thread_id
);
}
#define CHECK_STATUS(name) \
...
...
test/tests/compile_eval.py
View file @
9b30997a
print
compile
c
=
compile
(
"a"
,
"test.py"
,
"eval"
)
print
type
(
c
),
c
.
co_filename
,
c
.
co_name
...
...
test/tests/sys_test.py
View file @
9b30997a
import
sys
import
os.path
print
sys
.
excepthook
,
sys
.
displayhook
print
sys
.
version
[:
3
]
print
os
.
path
.
exists
(
sys
.
executable
)
print
sys
.
copyright
[
-
200
:]
...
...
Boxiang Sun
@Daetalus
mentioned in commit
15acc85c
·
Sep 08, 2016
mentioned in commit
15acc85c
mentioned in commit 15acc85cf27f540a18255c55ae73a702b933231f
Toggle commit list
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