码迷,mamicode.com
首页 > 编程语言 > 详细

使用线程队列

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

标签:out   href   mat   tag   css   time()   线程   art   apple   

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)

 

使用线程队列

标签:out   href   mat   tag   css   time()   线程   art   apple   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!