当前位置:网站首页>Day39 content summary
Day39 content summary
2022-06-11 09:18:00 【lwj_ 07】
Process object properties and their methods
from multiprocessing import Process,current_process
import os
current_process().pid # View the current process number
os.getpid() # View the current process number
os.getppid() # View the parent process number of the current process
"""
windows Terminal command
tasklist
tasklist |findstr PID
mac Terminal command
ps aux
ps aux|grep PID
"""Daemon
"""
After the daemon is finished, the daemon immediately ends
"""
# How to open stay start Just write the following code before the statement
p.daemon = True
p.start()The mutex
"""
When multiple people operate the same data, the data will be disordered
We usually lock the above problems
effect :
Turn concurrency into serial , It sacrifices the efficiency of program operation but ensures the security of data
Be careful :
Only lock the operation data
Try not to handle the lock by yourself It is easy to cause deadlock
Expand : Row lock Table locks
No one else can operate a row of data in the table
No one else can operate a table
"""
from multiprocessing import Lock
mutex = Lock()
# Grab the lock
mutex.acquire()
# Release the lock
mutex.release()
# Simulated ticket grabbing queue Queue
""" queue : fifo Stack : First in, then out """ from multiprocessing import Queue q = Queue() # Numbers can be placed in parentheses to limit the size of the queue q.put() # Put the data When the queue is full Blocking q.get() # Take the data Wait until the queue is empty Blocking q.full() # Determine if the queue is full q.empty() # Determine whether the queue is empty q.get_nowait() # If there is no data when retrieving data, an error will be reported directly q.get(timeout=5) # When retrieving data, if there is no data, etc 5s If not, it will directly report an errorInterprocess communication
""" There is no direct data interaction between processes , But data interaction can be realized through queues or pipelines The Conduit : queue : The Conduit + lock It is only possible to use it for local testing Queue, The actual production uses very powerful tools encapsulated by others redis kafka RQ """The producer and consumer model
""" producer + Message queue + consumer Why is there a message queue To solve the problem of imbalance between supply and demand """ # JoinableQueue """ Can be waited for q When you put data in the queue There is a counter inside that automatically adds 1 When you get data from a queue call task_done() The internal timer automatically decreases 1 q.join() When the counter is 0 And then continue to run """Thread theory
""" process : Resource units Threads : Executive unit Threads are the real workers , The resources needed in the process of working are provided by the process where the thread is located Each process must have its own thread Multiple threads can be created in the same process """ """ Open process Apply for memory space ” Copy code “ It consumes a lot of resources Start thread Create multiple threads in the same process These two operations are not required , The consumption of resources is relatively small Intelligence quotient (IQ) EQ Search business """
边栏推荐
- Development of PCBA circuit board for small oxygen generator
- 【服装ERP】施行在项目中的重要性
- Erreur de démarrage MySQL "BIND on TCP / IP Port: Address already in use"
- 剑指 Offer 06. 从尾到头打印链表
- Award winning survey streamnational sponsored 2022 Apache pulsar user questionnaire
- Runtimeerror: blobreader error:the version of imported blob doesn't match graph_ transformer
- 86. 分隔链表
- MySQL啟動報錯“Bind on TCP/IP port: Address already in use”
- Opencv CEO teaches you to use oak (V): anti deception face recognition system based on oak-d and depthai
- MSF给正常程序添加后门
猜你喜欢

Blinn Phong reflection model

openstack详解(二十四)——Neutron服务注册

Opencv CEO teaches you to use oak (V): anti deception face recognition system based on oak-d and depthai

Type-C蓝牙音箱单口可充可OTG方案
![[C language - data storage] how is data stored in memory?](/img/cb/2d0cc83fd77de7179a9c45655c1a2d.png)
[C language - data storage] how is data stored in memory?

Some learning records I=

ArcGIS 10.9.1 geological and meteorological volume metadata processing and service publishing and calling

Openstack explanation (22) -- neutron plug-in configuration

山东大学项目实训(四)—— 微信小程序扫描web端二维码实现web端登录

Exclusive interview with PMC member Liu Yu: female leadership in Apache pulsar community
随机推荐
Customize PCBA scheme and develop wrist sphygmomanometer scheme
Device = depthai Device(““, False) TypeError: _init_(): incompatible constructor arguments.
MSF evasion模块的使用
MySQL啟動報錯“Bind on TCP/IP port: Address already in use”
CUMT学习日记——ucosII理论解析—任哲版教材
445. adding two numbers II
2095. delete the intermediate node of the linked list
CUMT learning diary - theoretical analysis of uCOSII - Textbook of Renzhe Edition
203. remove linked list elements
【方案开发】血压计方案压力传感器SIC160
【芯片方案】红外人体测温仪方案设计
Machine learning notes - the story of master kaggle Janio Martinez Bachmann
移动端页面使用rem来做适配
考研數學 【數列極限證明題】題型方法總結
E. Zoom in and zoom out of X (operator overloading)
Machine learning notes - in depth Learning Skills Checklist
[share] how do enterprises carry out implementation planning?
报错RuntimeError: BlobReader error: The version of imported blob doesn‘t match graph_transformer
Typescript -- preliminary study of variable declaration
Machine learning notes - convolutional neural network memo list