背景: 某个应用场景需要从数据库中取出几十万的数据时,需要对每个数据进行相应的操作。逐个数据处理过慢,于是考虑对数据进行分段线程处理: 方法一:使用threading模块 代码: 1 # -*- coding: utf-8 -*- 2 import math 3 import random 4 im ...
分类:
编程语言 时间:
2019-12-12 10:25:32
阅读次数:
145
1.搭建HTTP静态Web服务器。 代码实现: 1 # 1.导入socket模块 2 import socket 3 import threading 4 5 6 # 创建服务器类 7 class HttpServerSocket(object): 8 # 给服务器类的对象设置属性 9 def __ ...
分类:
Web程序 时间:
2019-12-12 01:36:27
阅读次数:
125
队列形式 1 using System; 2 using System.Collections; 3 using System.IO; 4 using System.Text; 5 using System.Threading; 6 using System.Windows.Threading; 7 ...
分类:
其他好文 时间:
2019-12-11 12:37:15
阅读次数:
99
数据结构 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace 拼图 { /// <summary> ...
分类:
编程语言 时间:
2019-12-09 23:15:11
阅读次数:
171
1 # 1.导入socket模块 2 import socket 3 # import gevent 4 import threading 5 6 7 # 创建服务器类 8 class HttpServerSocket(object): 9 # 给服务器类的对象设置属性 10 def __init_ ...
分类:
编程语言 时间:
2019-12-08 23:47:22
阅读次数:
186
实现代码如下: #websocket协议通信 import threading import time import websocket def when_message(ws, message): print('/n接收到的消息:' + message) # 当建立连接后,死循环不断输入消息发送给 ...
分类:
编程语言 时间:
2019-12-08 14:07:23
阅读次数:
248
没有前端,多开了一条线程用于接收信息。 服务器端: # -*- coding:utf-8 -*- import socket import threading class Sock_Server: def __init__(self): self.host = '192.168.1.11' # 获取 ...
分类:
编程语言 时间:
2019-12-08 01:11:09
阅读次数:
69
使用with方式创建线程池,任务执行完毕之后,会自动关闭资源 , 否则就需要手动关闭线程池资源 import threading, time from concurrent.futures import ThreadPoolExecutor, as_completed class MyTask(th ...
分类:
编程语言 时间:
2019-12-07 21:03:58
阅读次数:
73
using System; using System.Collections.Generic; using System.Linq; using System.Windows.Forms; using System.Threading; namespace WindowsFormsApplicati ...
import threading,os,time,requests,pymongo,refrom queue import Queuefrom lxml import etreefrom bs4 import BeautifulSoup as BPclient = pymongo.MongoClie ...
分类:
编程语言 时间:
2019-12-06 11:40:39
阅读次数:
184