[Python编程(第4版)].(Programming.Python.4th.Edition).Mark.Lutz.文字版
import sys, os from threading import Thread mode = int(sys.argv[1]) if mode == 1: # run server in this process server() elif mod ...
Arbitrary Python objects like lists and dictionaries (or at least copies of them) can be transferred over sockets, too, by ship ...
interface, the script in Example 5-27 installs a Python handler function for the signal number passed in as a command-line argum ...
8380 7336 8380 428 con 1004 18:26:50 /usr/bin/ps $ kill −12 8224 Got signal 12 at Sun Mar 7 18:27:28 2010 $ kill −12 8224 Got si ...
Setting at Sun Mar 7 18:37:30 2010 ...Ctrl-C to exit... Generally speaking, signals must be used with cautions not made obvious ...
we’ve already studied? Before we get into the details, I want to begin with a few words about why you may (or may not) care abou ...
of a mutable message cache copied by pickling it to pass to a new process, for example, has no effect on the original. The pickl ...
def whoami(label, lock): msg = '%s: name:%s, pid:%s' with lock: print(msg % (label, name, os.getpid())) if name == 'main': lock ...
On Windows, it spawns a new interpreter by using Windows-specific process cre- ation tools, passing the pickled Process object ...
communication tools provided by this package, your code will usually be portable and correct. Let’s look next at a few of those ...
Most other Python object types, including classes and simple functions, work fine on pipes and queues. Also keep in mind that be ...
child.join() # wait for child exit print('parent exit') When run on Windows, here’s this script’s output—one child passes an obj ...
scalar = Value('i', 0) # shared memory: process/thread safe vector = Array('d', procs) # type codes from ctypes: int, double sho ...
show final results here # scalar=12: +6 parent, +6 in 6 children showdata('parent end', scalar, vector) # array[i]=8: +2 parent, ...
Example 5-32. PP4E\System\Processes\multi4.py """ Process class can also be subclassed just like threading.Thread; Queue works l ...
The exit status of child process is available after they finish in their exitcode attribute. When run, the output of the main ...
It is, however, possible to start new programs in the child processes spawned, using tools like the os.exec* calls we met earlie ...
And Much More Finally, multiprocessing provides many more tools than these examples deploy, in- cluding condition, event, and se ...
This precludes a common coding pattern that uses lambda to add data to calls, which we’ll use often for callbacks in the GUI par ...
Unfortunately, beyond this brief introduction, we don’t have space for a more complete treatment of this module in this book. Fo ...
«
10
11
12
13
14
15
16
17
18
19
»
Free download pdf