python-进程线程协程

python-进程,线程,协程源码

#-*- coding = utf-8 -*-
#Time : 2020/11/5 
#Author : 小柠檬
#File : 进程线程协程.py
import gevent.pool
import gevent.monkey
gevent.monkey.patch_all()
import requests
import json
import time
import urllib3
import threading
from multiprocessing import Process

urllib3.disable_warnings()

def lottery(a):
    print('大哥哥')
    
def geventMain():
    pool = gevent.pool.Pool()
    pool.map(lottery, (i for i in range(4)))

def threadMain():
    threads = (threading.Thread(target=geventMain) for _ in range(3))
    for i in threads:
        i.start()

def processMain():
    processes = (Process(target=threadMain) for _ in range(2))
    for i in processes:
        i.start()

if __name__ == '__main__':
    processMain()

你可能感兴趣的:(python-进程线程协程,多进程,多线程)