首页 > 编程语言 > 详细

使用线程队列

时间:2017-04-29 17:04:40      阅读:322      评论:0      收藏:0      [点我收藏+]

w

 

使用 Python 进行线程编程
https://www.ibm.com/developerworks/cn/aix/library/au-threadingpython/index.html

 

C:\>python E:\MATHpyCLI\url_fetch_serial.py
<!DOCTYPE html>
<html>
  <head>
    <meta charset=utf-8>
    <title>Redis</title>
    <link href=/styles.css rel=stylesheet>
    <link href=/images/favicon.png rel=shortcut icon>
    <link href=/opensearch.xml rel=search title=Look up a Redis command type=application/opensearchdescri
    <meta content=width=device-width, minimum-scale=1.0, maximum-scale=1.0 name=viewport>
    <script>
       var _gaq = _gaq || [];
       _gaq.push([_setAccount, UA-20243082-1]);
       _gaq.push([_trackPageview]);

       (function() {
         var ga = document.createElement(script); ga.type = text/javascript; ga.async = true;
         ga.src = (https: == document.location.protocol ? https://ssl : http://www) + .google-analytics.c
         var s = document.getElementsByTagName(script)[0]; s.parentNode.insertBefore(ga, s);
       })();
    </script>
  </head>
  <body class=‘‘>
    <div class=mobile-menu slideout-menu>
      <header class=menu-header></heade
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <link rel="icon" type="image/x-icon" href="/favicon.ico" />
    <link type="text/css" href="/css/pages.css" media="all" rel="stylesheet">

    <!-- Begin Jekyll SEO tag v2.2.0 -->
<title>GitHub Pages | Websites for you and your projects, hosted directly from your GitHub repository. Just edit
<meta property="og:title" content="GitHub Pages" />
<meta property="og:locale" content="en_US" />
<meta name="description" content="Websites for you and your projects, hosted directly from your GitHub repositor
<meta property="og:description" content="Websites for you and your projects, hosted directly from your GitHub re
<link rel="canonical" href="https://pages.github.com/" />
<meta property="og:url" content="https://pages.github.com/" />
<meta property="og
Elapsed Time: 20.3339998722

C:\>

 

url_fetch_serial.py

import urllib2
import time
#hosts = ["https://apple.com","https://ibm.com","https://amazon.com"]
hosts = ["https://redis.io","http://github.io"]

start = time.time()

for host in hosts:
    url = urllib2.urlopen(host)
    print url.read(1024)
print "Elapsed Time: %s" % (time.time()-start)

 

使用线程队列

原文:http://www.cnblogs.com/yuanjiangw/p/6785499.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!