E-COM-NET
首页
在线工具
Layui镜像站
SUI文档
联系我们
推荐频道
Java
PHP
C++
C
C#
Python
Ruby
go语言
Scala
Servlet
Vue
MySQL
NoSQL
Redis
CSS
Oracle
SQL Server
DB2
HBase
Http
HTML5
Spring
Ajax
Jquery
JavaScript
Json
XML
NodeJs
mybatis
Hibernate
算法
设计模式
shell
数据结构
大数据
JS
消息中间件
正则表达式
Tomcat
SQL
Nginx
Shiro
Maven
Linux
Python多线程
Python多线程
之start_new_thread
#coding=gbk#Python中的线程处理'''Python中对多线程有两种启动方法:一种是thread模块的start_new_thread方法,在线程中运行一个函数,但获得函数返回值极为困难,Python官方不推荐另一种是集成threading模块的Thread类,然后重写run方法,类似于Java的Runnable接口定义,灵活性较高'''print"=================
fangxingxing007
·
2012-10-22 09:50
Python基础
Python
Python多线程
之start_new_thread
#coding=gbk #Python中的线程处理 ''' Python中对多线程有两种启动方法: 一种是thread模块的start_new_thread方法,在线程中运行一个函数,但获得函数返回值极为困难,Python官方不推荐 另一种是集成threading模块的Thread类,然后重写run方法,类似于Java的Runnable接口定义,灵活性较高 ''' print
剑锋凛冽
·
2012-10-22 09:00
thread
实现可中断的线程
在《从nginx日志读取URL来做性能测试》(http://san-yun.iteye.com/blog/1679215)这篇文章中我实现了一个
python多线程
来做性能测试,但存在一个问题,线程不可中断
san_yun
·
2012-09-25 15:00
线程
Python多线程
学习
Python代码代码的执行由python虚拟机(也叫解释器主循环)来控制。Python在设计之初就考虑到要在主循环中,同时只有一个线程在执行,就像单CPU的系统中运行多个进程那样,内存中可以存放多个程序,但任意时候,只有一个程序在CPU中运行。同样,虽然python解释器可以“运行”多个线程,但在任意时刻,只有一个线程在解释器中运行。(据说新版本有考虑) python支
kasagawa
·
2012-08-09 14:00
thread
timer
python
Module
import
loops
Python多线程
学习
&nbs
逸情公子
·
2012-08-08 14:00
python 多线程
Python多线程
学习
&nbs
逸情公子
·
2012-08-08 14:00
python 多线程
Python多线程
PING工具
最近用python写了一个PING工具,使用了两种写法,非OOP与OOP。一、非OOP代码#!/usr/bin/envpythonfromthreadingimportThreadimportsubprocessfromQueueimportQueue#指定线程数量num_threads=3#申明一个队列queue=Queue()ips=["172.18.17.34","172.18.17.35"
zell_h
·
2012-07-14 15:55
PING工具
Python多线程
ping检测机器存活(跨平台版)
由于日常工作经常要回收开发商用完的服务器,之前是用nmap检测开发商有没有关机的,感觉挺麻烦的,今天拿python写了一个脚本专门对付回收服务器的:原理:把准备回收的机器写入hosts.txt文件里,python脚本读取hosts.txt文件的内容,匹配出里面的ip,然后通过ping测试服务器是否没关机#!/usr/bin/env python from threading import Thr
lihuipeng
·
2012-07-09 15:44
ping
python
Python与运维
Python多线程
ping检测机器存活(跨平台版)
由于日常工作经常要回收开发商用完的服务器,之前是用nmap检测开发商有没有关机的,感觉挺麻烦的,今天拿python写了一个脚本专门对付回收服务器的:原理:把准备回收的机器写入hosts.txt文件里,python脚本读取hosts.txt文件的内容,匹配出里面的ip,然后通过ping测试服务器是否没关机 #!/usr/bin/env python from threadi
lihuipeng
·
2012-07-09 15:44
python
ping
Python多线程
ping检测机器存活(windows版)
由于日常工作经常要回收开发商用完的服务器,之前是用nmap检测开发商有没有关机的,感觉挺麻烦的,今天拿python写了一个脚本专门对付回收服务器的:原理:把准备回收的机器写入hosts.txt文件里,python脚本读取hosts.txt文件的内容,匹配出里面的ip,然后通过ping测试服务器是否没关机 #!/usr/bin/env python from threadin
lihuipeng
·
2012-07-09 14:39
windows
python
ping
基于内存共享的并行排序算法慢谈
这不还是碰到了,请听题:请用
Python多线程
对一个4G以上的文件, 进行外排序,尽量优化性能。
HackerVirus
·
2012-06-29 14:00
python多线程
模块threadpool简单使用
python实现线程池通常使用threading或thread模块来编写,现在已经有了threadpool模块来实现线程池。英文文档见:http://www.chrisarndt.de/projects/threadpool/中文文档见:http://gashero.yeax.com/?p=44现给出一个简易的使用threadpool模块来实现线程池的例子:importthreadpool imp
Plutus_Lee
·
2012-06-18 16:00
thread
多线程
python
文档
import
python多线程
模块threadpool简单使用
python实现线程池通常使用threading或thread模块来编写,现在已经有了threadpool模块来实现线程池。英文文档见:http://www.chrisarndt.de/projects/threadpool/中文文档见:http://gashero.yeax.com/?p=44现给出一个简易的使用threadpool模块来实现线程池的例子: #!/usr/bin
dgfpeak
·
2012-05-12 22:50
thread
多线程
python
模块
英文
Python多线程
thread与threading实现
Python多线程
thread与threading实现[Python俱乐部]
Python多线程
thread与threading实现python是支持多线程的,并且是native的线程。
·
2012-05-12 22:00
reading
python多线程
编程(6): 队列同步
让我们考虑更复杂的一种场景:产品是各不相同的。这时只记录一个数量就不够了,还需要记录每个产品的细节。很容易想到需要用一个容器将这些产品记录下来。Python的Queue模块中提供了同步的、线程安全的队列类,包括FIFO(先入先出)队列Queue,LIFO(后入先出)队列LifoQueue,和优先级队列PriorityQueue。这些队列都实现了锁原语,能够在多线程中直接使用。可以使用队列来实现线程
索隆
·
2012-05-02 21:00
Python多线程
学习
一、Python中的线程使用: Python中使用线程有两种方式:函数或者用类来包装线程对象。1、 函数式:调用thread模块中的start_new_thread()函数来产生新线程。如下例: viewplaincopytoclipboardprint?import time import thread def timer(no, interval): cnt = 0
charlesdong1989
·
2012-03-23 19:00
关于python中的多线程与并发
关于python中的多线程与并发 在用
python多线程
构造并发请求的时候,遇到如下的“thread.error: can't start new
bluky999
·
2012-03-22 22:00
多线程
并发
python
socket
stackless
python多线程
编程(8):线程的合并和后台线程
线程的合并python的Thread类中还提供了join()方法,使得一个线程可以等待另一个线程执行结束后再继续运行。这个方法还可以设定一个timeout参数,避免无休止的等待。因为两个线程顺序完成,看起来象一个线程,所以称为线程的合并。一个例子:importthreadingimportrandomimporttimeclassMyThread(threading.Thread):defrun(
·
2012-03-21 16:00
python
python多线程
编程(7):线程间通信
很多时候,线程之间会有互相通信的需要。常见的情形是次要线程为主要线程执行特定的任务,在执行过程中需要不断报告执行的进度情况。前面的条件变量同步已经涉及到了线程间的通信(threading.Condition的notify方法)。更通用的方式是使用threading.Event对象。threading.Event可以使一个线程等待其他线程的通知。其内置了一个标志,初始值为False。线程通过wait
·
2012-03-21 06:00
python
python多线程
编程(6): 队列同步
前面介绍了互斥锁和条件变量解决线程间的同步问题,并使用条件变量同步机制解决了生产者与消费者问题。让我们考虑更复杂的一种场景:产品是各不相同的。这时只记录一个数量就不够了,还需要记录每个产品的细节。很容易想到需要用一个容器将这些产品记录下来。Python的Queue模块中提供了同步的、线程安全的队列类,包括FIFO(先入先出)队列Queue,LIFO(后入先出)队列LifoQueue,和优先级队列P
·
2012-03-15 14:00
python
python多线程
编程(4): 死锁和可重入锁
死锁在线程间共享多个资源的时候,如果两个线程分别占有一部分资源并且同时等待对方的资源,就会造成死锁。尽管死锁很少发生,但一旦发生就会造成应用的停止响应。下面看一个死锁的例子:#encoding:UTF-8importthreadingimporttimeclassMyThread(threading.Thread):defdo1(self):globalresA,resBifmutexA.acqu
·
2012-03-08 16:00
python
一些有意思的问题和解答(未完待续)
一直觉得面试就是一个交互的过程,在面试中也经常碰到一些自己不会甚至没有听过的问题,把这些问题记录在这里,也顺便Google一下学习一下^_^(这篇文章还在持续更新中,如果有些问题没有回答好,可能还会更新)1.
Python
ankyhe
·
2012-02-21 10:47
技术_程序设计_Python
技术_程序设计_C++
一些有意思的问题和解答(未完待续)
Python多线程
有什么问题? 不知道这个问题的答案,我觉得蛮遗憾的。虽然用了Python两三年了,偶尔也用到multithread
ankyhe
·
2012-02-21 10:00
问题
一些有意思的问题和解答(未完待续)
一直觉得面试就是一个交互的过程,在面试中也经常碰到一些自己不会甚至没有听过的问题,把这些问题记录在这里,也顺便Google一下学习一下^_^(这篇文章还在持续更新中,如果有些问题没有回答好,可能还会更新)1.
Python
ankyhe
·
2012-02-21 10:00
python多线程
读取文件
#-*-coding:utf-8-*-importos,timeimportthreadingrlock=threading.RLock()curPosition=0classReader(threading.Thread):def__init__(self,res):self.res=ressuper(Reader,self).__init__()defrun(self):globalcurPo
wanyanxgf
·
2012-02-10 10:00
多线程
python
object
OS
Class
Python多线程
批量部署脚本
所需软件:python2.7.tar.bz2paramiko-1.7.7.1.tar.gz pycrypto-2.3.tar.gz 所需文件内容格式为:IP,sshPort,Username,Password 执行:python2.7脚本名 结果: 有些朋友可以考虑到密码明文的问题,目前这个版本没设置任何加密因为目前还不需要。不过密码安全不是问题,最简单的例子,我的密码是6位,现在给出一串字符
单身贵族liu
·
2012-02-02 13:04
python
职场
批量部署
休闲
多核CPU上
python多线程
并行的一个假象
python-cn(华蟒用户组,CPyUG邮件列表)上: 关于
python多线程
是否能用到多核的问题 相关讨论本机环境:2核CPU,linux2.6,python2.6.2 在python上开启多个线程
chobit_s
·
2011-12-19 10:00
多线程
linux
python
OS
Python多线程
Socket程序例子
如果没有multitask包,请从http://python-multitask.googlecode.com/files/multitask-0.2.0.zip下载或从http://code.google.com/p/python-multitask/downloads/list?can=1查找最新版本http://ghostfromheaven.iteye.com/admin/blogs/13
GhostFromHeaven
·
2011-12-11 16:00
Python多线程
Socket程序例子
如果没有multitask包,请从[url]http://python-multitask.googlecode.com/files/multitask-0.2.0.zip[/url]下载[url]http://blog.csdn.net/ghostfromheaven/article/details/7061387[/url][size=medium]server端[/size]from__fu
iteye_21281
·
2011-12-11 16:45
Python2.7
Python多线程
Socket程序例子
如果没有multitask包,请从 http://python-multitask.googlecode.com/files/multitask-0.2.0.zip下载 http://blog.csdn.net/ghostfromheaven/article/details/7061387 server端 from __future__ import with_sta
GhostFromheaven
·
2011-12-11 16:00
多线程
python
socket
multitask
python多线程
Python 中使用线程有两种方式:函数或者用类来包装线程对象。1、 函数式:调用thread模块中的start_new_thread()函数来产生新线程。如下例: viewplain copytoclipboard print ?import time import thread def timer(no, interval): cnt = while cnt= 5:
索隆
·
2011-12-10 23:00
python多线程
模块threading简例
#!/usr/bin/python #-*-coding:utf-8-*- fromthreadingimportThread fromdatetimeimportdatetime defdotest(str): printstr,datetime.now() classmythread(Thread): def__init__(self,target,args,name='myname'
five3
·
2011-12-09 23:00
python多线程
解析
Python中使用线程有两种方式:函数或者用类来包装线程对象。1、 函数式:调用thread模块中的start_new_thread()函数来产生新线程。如下例: viewplaincopytoclipboardprint?import time import thread def timer(no, interval): cnt = while cnt= 5:
minicase
·
2011-12-06 18:00
python
python多线程
解析
Python中使用线程有两种方式:函数或者用类来包装线程对象。1、 函数式:调用thread模块中的start_new_thread()函数来产生新线程。如下例: viewplaincopytoclipboardprint?import time import thread def timer(no, interval): cnt = while cnt= 5:
minicase
·
2011-12-06 18:00
python
Python 学习积累《三》 多线程
Python多线程
学习原文地址:http://www.cnblogs.com/tqsummer/archive/2011/01/25/1944771.html 一、Python中的线程使用: Python
achang21
·
2011-09-24 10:00
thread
多线程
exception
timer
python
Module
python 下载文件
之前给大家分享的
python多线程
抓取网页,我觉的大家看了以后,应该会对python抓取网页有个很好的认识,不过这个只能用python来抓取到网页的源代码,如果你想用做python下载文件的话,上面的可能就不适合你了
[email protected]
(laowang) Eric
·
2011-07-27 11:00
python练习题
Python多线程
实例
from threading import Thread class Task(Thread): def __init__(self, count): super(Task, self).__init__() #Thread.__init__(self) self.count = count def run(self)
rokuan
·
2011-07-26 22:00
python
Python 多线程
在早期的
Python多线程
实现中,采用了thread模块。
bestchenwu
·
2011-07-21 09:00
多线程
thread
python
Blog
ITeye
Python多线程
原文:http://blog.csdn.net/lazy_tiger/article/details/3861844 一、Python中的线程使用: Python中使用线程有两种方式:函数或者用类来包装线程对象。1、 函数式:调用thread模块中的start_new_thread()函数来产生新线程。如下例:importtimeimportthreaddeftimer(no,interval
Cain
·
2011-07-11 17:00
Python 多线程编程及同步处理
美中不足的是,Python的运行在Python虚拟机上,创建的多线程可能是虚拟的线程,需要由Python虚拟机来轮询调度,这大大降低了
Python多线程
的可用性。希望高版
andylin02
·
2011-06-17 13:00
thread
多线程
编程
虚拟机
python
Python多线程
编程
http://hi.baidu.com/houhl/blog/item/e58251092ea969ad2fddd46b.html
zhangfn2011
·
2011-06-01 10:00
Python多线程
(1)
开发多线程的应用系统,是在日常的软件开发中经常会遇到的需求。现在的编程语言都为多线程开发提供了很好的支持,无论是通过库的支持还是将多线程机制内建在语言之中。Python也为多线程系统的开发提供了很好的支持。同样身为动态语言,Ruby也提供了多线程的支持,但是在Ruby1.9之前的多线程机制是在语言的实现中模拟了线程及线程调度机制,而并没有使用操作系统本身的线程机制(在以后的描述中,我们称为原生线
majieyue
·
2011-03-17 19:00
多线程
虚拟机
python
Ruby
语言
branch
PYTHON多线程
同步的几种方法
转载:一篇中文的http://www.cnblogs.com/huxi/archive/2010/06/26/1765808.html一篇英文的http://effbot.org/zone/thread-synchronization.htm
wh62592855
·
2011-03-04 15:00
多线程
python
2010
Python多线程
简明例子
转自:crazier9527的博客 http://crazier9527.javaeye.com/blog/442101 综述 多线程是程序设计中的一个重要方面,尤其是在服务器Deamon程序方面。无论何种系统,线程调度的开销都比传统的进程要快得多。 Python可以方便地支持多线程。可以快速创建线程、互斥锁、信号量等等元素,支持线程读写同步互斥。美中不足的是,Python的运行在Python
vah101
·
2011-02-14 16:00
thread
多线程
虚拟机
python
Class
jython
Python多线程
忍无可忍,今天把python3.1换到了2.7,不然每次发现写个代码编译不过我就得去查这是不是又是3.0的改变之处!我还是个初学者,没那么多时间在那上纠结! Whymulti-thread?Multiplethreadswithinaprocesssharethesamedataspacewiththemainthreadandcanthereforeshareinformationorcomm
carolzhang8406
·
2010-12-27 16:00
JOIN
thread
多线程
python
function
delay
python多线程
ping网络地址
有时候上网比较卡,于是想看看局域网中有哪些ip是出于活动状态。用python实现了下,简单的多线程调用操作系统的ping.exe,代码如下:Python语言: 临时自用代码import osimport reimport timeimport sysfrom threading import ThreadaliveInfo = re.compile(r"Received=1")status = (
synelang
·
2010-11-17 22:00
多线程
python
ping
Python多线程
编程的两种方式
Python中如果要使用线程的话,python的lib中提供了两种方式。一种是函数式,一种是用类来包装的线程对象。(例子已经稍加修改)1、调用thread模块中的start_new_thread()函数来产生新的线程,请看代码: Python语言: 临时自用代码import timeimport threadimport sysTIMEOUT = 20def myThread(no, interv
synelang
·
2010-11-17 22:00
多线程
python
Python多线程
编程
本文转自http://crazier9527.javaeye.com/blog/442100 我们在做软件开发的时候很多要用到多线程技术。例如如果做一个下载软件象flashget就要用到、象在线视频工具realplayer也要用到因为要同时下载mediastream还要播放。其实例子是很多的。线程相对进程来说是“轻量级”的,操作系统用较少的资源创建和管理线程。程序中的线程在相同的内存空间中执行,并
wh62592855
·
2010-11-13 16:00
JOIN
thread
多线程
python
processing
import
nginx配置ghs.google.com反向代理
blog.stevenwang.name/nginx-reverse-proxy-122001.html python安全管理子进程-subprocess-python-Python-JavaEye论坛python管理子进程(原创)-
python
·
2010-09-09 22:00
Google
通过
python多线程
访问网页
通过
python多线程
访问网页@for&ever2010-07-03 通过python,采用多线程的方式访问网页。一个简单的小例子,访问三个不同的页面,每个页面开20个线程并发访问。
forandever
·
2010-07-03 21:00
多线程
exception
python
url
import
2010
上一页
34
35
36
37
38
39
40
41
下一页
按字母分类:
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
其他