当前位置:网站首页>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 """
边栏推荐
- 从企业评价的方历来看ERP软件成功与失利
- Telecommuting best practices and Strategies
- Error [error] input tesnor exceeded available data range [neuralnetwork (3)] [error] input tensor '0' (0)
- Comparison and introduction of OpenCV oak cameras
- 基于SIC32F911RET6设计的腕式血压计方案
- 【分享】企业如何进行施行规划?
- Typescript -- preliminary study of variable declaration
- Opencv CEO teaches you to use oak (V): anti deception face recognition system based on oak-d and depthai
- 【方案开发】血压计方案压力传感器SIC160
- 1854. 人口最多的年份
猜你喜欢

Device = depthai Device(““, False) TypeError: _init_(): incompatible constructor arguments.

Exclusive interview with PMC member Liu Yu: female leadership in Apache pulsar community

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

Talk about reading the source code

Machine learning notes - spatial transformer network using tensorflow

Complexity analysis of matrix inversion operation (complexity analysis of inverse matrix)

考研數學 【數列極限證明題】題型方法總結

Openstack explanation (24) -- registration of neutron service

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

CUMT learning diary - theoretical analysis of uCOSII - Textbook of Renzhe Edition
随机推荐
Award winning survey streamnational sponsored 2022 Apache pulsar user questionnaire
Design of wrist sphygmomanometer based on sic32f911ret6
openstack详解(二十二)——Neutron插件配置
Openstack explanation (24) -- registration of neutron service
Customize PCBA scheme and develop wrist sphygmomanometer scheme
Opencv oak-d-w wide angle camera test
Comment l'entreprise planifie - t - elle la mise en oeuvre?
【分享】企業如何進行施行規劃?
实现边充边OTG的PD芯片GA670-10
Typescript -- preliminary study of variable declaration
[237. delete nodes in the linked list]
What are the types of garment ERP system in the market?
Machine learning notes - the story of master kaggle Janio Martinez Bachmann
[share] how do enterprises carry out implementation planning?
Pulsar job Plaza | Tencent, Huawei cloud, shrimp skin, Zhong'an insurance, streamnational and other hot jobs
面试题 17.10. 主要元素
Complexity analysis of matrix inversion operation (complexity analysis of inverse matrix)
How win10 Home Edition connects to remote desktop
shell脚本之sed详解 (sed命令 , sed -e , sed s/ new / old / ... )
86. separate linked list