review:
C / S architecture: client-server mode
B / S architecture: the browser server mode
Client B / S structure of the PC performance requirements are relatively low. Unified interface applications
B / S architecture under C / S architecture
TCP UDP difference:
TCP connection-oriented, reliable byte stream oriented
UDP does not face the connection, unreliable, speed, packet-oriented
TCP stick package will occur:
Stick package: data chaos after the sender sends the data, the receiver does not know how to accept it.
Co-sourcing mechanism: Nagle algorithm
Unpacking mechanism
Note: Only the TCP protocol will occur stick package
arp protocol: To get to the destination by IP address of the destination MAC address
Five-layer OSI model:
Application layer http, https, ftp
Transport layer tcp, udp
Ip network layer protocol
The data link layer protocol card arp
The physical layer network cable, electrical signals, the hub
The difference between switches and routers?
Tissue LAN switch is mainly used, information transmission between the same network segment
Router: west-southwest transmission is mainly used in the inter-network routing the best path
Exchange of communication:
Unicast: Point to Point
Broadcast: roar of a voice
Multicast: point to multipoint (or a set of more than one)
How to determine whether the two computers in the same network segment?
Subnet mask & ip address
Concurrent and Parallel
Concurrency: multiple tasks simultaneously within the same time period
Parallel: the same time multiple tasks simultaneously
The difference between process and thread?
Process: is the basic unit of resource allocation
Thread: is the smallest unit of execution, the thread can not have the resources alone, and must rely on your process
When the compute-intensive, multi-process better .IO intensive, multi-threading
GIL lock: Global Interpreter Lock, lock the thread is to ensure the same time allowing only one thread to access cpu.
Mutex: a lock with a key used to protect data security.
Shared resources, also known as the critical resources to share code and the code is called critical
When critical resources to operate, be sure to lock
Recursive lock: a master key with a lot of locks
signal:
It is also used to protect data security
A lock with a lot of keys
event:
wait () bool value determination is_set, and if True, wait nonblocking
is_set refers to the set of bool set to True
is_set logo
The clear value to False is_set
Multithreading also learn:
condition
Timer: Timer (t, func)
Communications between multiple processes:
Queues and pipes
Queues are safe. + Conduit lock queue =
Pipe is insecure
Producers and consumers to achieve a model queue
This model is mainly for decoupling
Process module pool: Pool
p.map()
p.apply: submit task synchronization
p.apply_async () asynchronous tasks submission
The callback function: In the process pool, the callback function is called the parent process
Today's content:
1 queue (multi-process) within the same process
import queue
queue.Queue () FIFO
queue.LifoQueue () LIFO
queue.PrioritQueue () priority queue
Priority queue q = queue.PriorityQueue ()
q.put () received a tuple
The first parameter tuple is: indicates the current priority data
The second tuple parameters are: the need to store data queue
Comparing the priority (first ensure that the entire queue, all numbers expressing same priority type)
If size is int, compare the value of
If you are str, string comparison of size (from start comparing the ASCII code of the first character)
2 thread pool
In a pool, put a fixed number of threads that wait for the task, once the task, there is a ready-made spontaneous tasks.
concurrent.futures This module is a mechanism called asynchronous
concurrent.futures tasks are submitted by submit
for + submit multiple tasks submitted
shutdown is equivalent to the Pool of close + join, is a task that does not allow to continue to increase in the pool, and then let the parent process (thread) to wait for all processes in the pool after executing all tasks
.
How it multiple tasks thrown into the pool?
Different ways to submit multiple tasks (for + submit or map), do not have a way to get results
If it is for + submit the submission tasks, take the results with a result method
If the map mode is mentioned task, the result is a generator using the __next __ () get results manner
About callback function, regardless of process pool Pool manner, or ProcrssPoolExecutor way open process pool
Callback functions are called by the parent process
About callback function, ThreadPoolExecutor
Who calls the callback function ??????