mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 19:40:18 +00:00
Update threading.md
This commit is contained in:
parent
e81dc95e6f
commit
01418a7144
@ -139,6 +139,15 @@ Frame: 4
|
|||||||
World Generation Complete 3 10000 10
|
World Generation Complete 3 10000 10
|
||||||
```
|
```
|
||||||
|
|
||||||
`ComputeThread` used `pickle` module to serialize the data between threads.
|
`ComputeThread` uses `pickle` module to serialize the data between threads.
|
||||||
So parameters and return values must be supported by `pickle`.
|
Parameters and return values must be supported by `pickle`.
|
||||||
See [pickle](https://pocketpy.dev/modules/pickle/) for more details.
|
See [pickle](https://pocketpy.dev/modules/pickle/) for more details.
|
||||||
|
|
||||||
|
Since `ComputeThread` is backed by a separate `VM` instance,
|
||||||
|
it does not share any state with the main thread
|
||||||
|
except for the parameters you pass to it.
|
||||||
|
Therefore, common python modules will be imported twice in each thread.
|
||||||
|
|
||||||
|
If you want to identify which VM instance the module is running in,
|
||||||
|
you can call `pkpy.currentvm` or let your `ComputeThread` set some special flags
|
||||||
|
before importing these modules.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user