OS. fork (), OS. fork
Ret = OS. fork () if ret = 0: child_suite # sub-process code else: parent_suite # parent Process Code
The fork () function in Python can obtain the PID (Process ID) of the Process in the system. If 0 is returned, it is a sub-Process. Otherwise, it is the parent Process, and then the running Process can be operated accordingly;
However, powerful fork () functions cannot be used in Python of Windows... It can only be used in Linux systems, such as Ubuntu 15.04. getpid () can be used to obtain the parent process ID in Windows ().
The following other OS. functions cannot be used in Windows:
| Uname (), |
Obtain system information (host name, operating system version, patch level, system architecture, etc) |
| Getuid (), |
GET/set the real User ID of the current process |
| Getgid (), |
GET/set the group ID of the current process |
| Getsid (), |
Obtain the session ID or create and return a new SID. |
| Geteuid (), |
GET/set the valid user ID (GID) of the current process) |
| Getegid (), |
Obtain/set the group ID (GID) of the current process) |
| Getpgid (), |
Get/set process GID process PID: For get, if pid is 0, the current process GID is returned |
| Getlogin (), |
Returns the user logon result of the current process. |
| Getloadavg (); |
Returns the ancestor of the average system load value in the past 1, 5, and 15 minutes. |
This is why most Server clusters are deployed in Linux, not only because the applications are deployed in Linux in a stable and smooth system, but more importantly, the functions of various tool sdks are improved.