zoukankan      html  css  js  c++  java
  • python 多线程测试

    [oracle@node01 ~]$ sqlplus / as sysdba
    
    SQL*Plus: Release 11.2.0.4.0 Production on 星期二 8月 22 10:00:12 2017
    
    Copyright (c) 1982, 2013, Oracle.  All rights reserved.
    
    ERROR:
    ORA-00020: maximum number of processes (40) exceeded
    
    
    请输入用户名:  
    
    
       	USERNAME	MACHINE	STATUS	PREV_SQL_ADDR	PREV_HASH_VALUE	PREV_SQL_ID	PROCESS	MODULE	COUNT(1)
    7		node01	ACTIVE	0000000061AF14A0	139075864	cv959u044n88s	2053	Streams	1
    5	SYSTEM	WORKGROUPTLCB-PC	INACTIVE	00000000619DC608	2625984628	4g8r4bkf8aq3n	7844:6096	python.exe	1
    3	SYSTEM	WORKGROUPTLCB-PC	INACTIVE	00000000619D3330	3677762709	55tzs9gdmcd4p	7844:7988	python.exe	1
    8	SYSTEM	WORKGROUPTLCB-PC	INACTIVE	00000000619D9C08	3886790535	01tjnxmmurdw7	7844:7520	python.exe	1
    2	SYSTEM	WORKGROUPTLCB-PC	INACTIVE	00000000619CF220	4177245906	a1hg7hrwgrdqk	7844:4176	python.exe	1
    9		node01	ACTIVE	00	0		2005		1
    11		node01	ACTIVE	0000000061AD85F8	2886642122	1ptv0pqq0xafa	2015		1
    10		node01	ACTIVE	0000000061ACD370	4052085454	chsyr0gssbuqf	2013		1
    1		node01	ACTIVE	0000000061BA9658	1570213724	bsa0wjtftg3uw	2019		1
    4		node01	ACTIVE	00	0		1989		1
    6		node01	ACTIVE	00	0		2009		1
    12	SYSTEM	WORKGROUPTLCB-PC	INACTIVE	0000000061B22F80	3403569819	3nz260v5dwqnv	7344:7348	PL/SQL Developer	1
    13	SYSTEM	WORKGROUPTLCB-PC	INACTIVE	00000000619CDF38	3414728260	4v01fvb5sj7k4	7844:8040	python.exe	1
    14		node01	ACTIVE	00	0		1997		1
    15	SYSTEM	WORKGROUPTLCB-PC	INACTIVE	00000000619D8708	318884020	2jzx0889h3k5n	7844:6528	python.exe	1
    16	SYSTEM	WORKGROUPTLCB-PC	INACTIVE	0000000061BAA318	1385873140	a2b6nvx99pgrn	7280:3588	PL/SQL Developer	1
    17		node01	ACTIVE	000000009E061A28	1129083356	8wxxddd1nswfw	2001		1
    18		node01	ACTIVE	00	0		1993		1
    19	SYSTEM	WORKGROUPTLCB-PC	INACTIVE	00000000619CB968	696840091	g5ph474nsjvwv	7844:7268	python.exe	1
    20	SYSTEM	WORKGROUPTLCB-PC	INACTIVE	0000000061B1EA40	356401299	9m7787camwh4m	7344:7348	PL/SQL Developer	1
    21		node01	ACTIVE	00	0		1991		1
    22		node01	ACTIVE	00	0		2003		1
    23		node01	ACTIVE	00	0		2011		1
    24		node01	ACTIVE	000000009E1620E0	3489409389	aykvshm7zsabd	2017		1
    25		node01	ACTIVE	00	0		2007		1
    26	SYSTEM	WORKGROUPTLCB-PC	INACTIVE	00000000619D56C8	1322799368	awtzfbx7dhn88	7844:8004	python.exe	1
    27		node01	ACTIVE	000000009E13E028	1023521005	cb21bacyh3c7d	2055	Streams	1
    28	SYSTEM	WORKGROUPTLCB-PC	INACTIVE	00000000619D2048	3801683775	87mdhpgj9k5tz	7844:7880	python.exe	1
    29	SYSTEM	WORKGROUPTLCB-PC	INACTIVE	00000000619DA8B0	2001791421	1rx9mjdvp1udx	7844:8076	python.exe	1
    30		node01	ACTIVE	00	0		1999		1
    31	SYSTEM	WORKGROUPTLCB-PC	INACTIVE	00000000619D18A8	1851725899	39bcsfjr5y62b	7844:7668	python.exe	1
    32	SYSTEM	WORKGROUPTLCB-PC	INACTIVE	00000000619D7A60	2857913792	fqjuj4qp5hmf0	7844:7428	python.exe	1
    33	SYSTEM	WORKGROUPTLCB-PC	INACTIVE	00000000619DD8E8	798626349	928r7khrtn4jd	7844:7352	python.exe	1
    34	SYSTEM	WORKGROUPTLCB-PC	INACTIVE	00000000619CCC50	724800223	d6sgjjwpm74qz	7844:6972	python.exe	1
    35		node01	ACTIVE	000000009E132740	2230961768	79w2cqu2gmjm8	2033	Streams	1
    36	SYSTEM	WORKGROUPTLCB-PC	ACTIVE	0000000061B1EA40	356401299	9m7787camwh4m	7344:7348	PL/SQL Developer	1
    
    
    C:UsersTLCB>netstat -na | findstr 53048
      TCP    192.168.137.1:53048    192.168.137.2:1521     ESTABLISHED
    
    C:UsersTLCB>netstat -nao | findstr 53048
      TCP    192.168.137.1:53048    192.168.137.2:1521     ESTABLISHED     7844
    
    C:UsersTLCB>netstat -nao | findstr 54042
    
    C:UsersTLCB>netstat -nao | findstr 53042
      TCP    192.168.137.1:53042    192.168.137.2:1521     ESTABLISHED     7844
    
    C:UsersTLCB>netstat -nao | findstr 53046
      TCP    192.168.137.1:53046    192.168.137.2:1521     ESTABLISHED     7844
    
    C:UsersTLCB>netstat -nao | findstr 53036
      TCP    192.168.137.1:53036    192.168.137.2:1521     ESTABLISHED     7844
    
    
    windows上一个进程引发的多个线程
    
    
    
    #coding=utf-8
    import threading
    import time
    import cx_Oracle
    from pprint import pprint
    import csv
    table_name = "dbtest.csv"
    f = open(table_name + ".csv", "w")
    
    def exp01():
        conn = cx_Oracle.connect('system/oracle@192.168.137.2/serv')
        cursor = conn.cursor()
        owner = "system"
        writer = csv.writer(f, lineterminator="
    ", quoting=csv.QUOTE_NONNUMERIC)
        tname = threading.current_thread()
        print tname
        exportOracleSql = "select 'exp01' from dual"
        print exportOracleSql
        x = cursor.execute(exportOracleSql)
        time.sleep(1000)
        cursor.close()
        conn.close()
    
    def exp02():
        conn = cx_Oracle.connect('system/oracle@192.168.137.2/serv')
        cursor = conn.cursor()
        owner = "system"
        writer = csv.writer(f, lineterminator="
    ", quoting=csv.QUOTE_NONNUMERIC)
        tname = threading.current_thread()
        print tname
        exportOracleSql = "select 'exp02' from dual"
        print exportOracleSql
        x = cursor.execute(exportOracleSql)
        time.sleep(1000)
        cursor.close()
        conn.close()
    
    def exp02():
        conn = cx_Oracle.connect('system/oracle@192.168.137.2/serv')
        cursor = conn.cursor()
        owner = "system"
        writer = csv.writer(f, lineterminator="
    ", quoting=csv.QUOTE_NONNUMERIC)
        tname = threading.current_thread()
        print tname
        exportOracleSql = "select 'exp02' from dual"
        print exportOracleSql
        x = cursor.execute(exportOracleSql)
        time.sleep(1000)
        cursor.close()
        conn.close()
    
    def exp03():
            conn = cx_Oracle.connect('system/oracle@192.168.137.2/serv')
            cursor = conn.cursor()
            owner = "system"
            writer = csv.writer(f, lineterminator="
    ", quoting=csv.QUOTE_NONNUMERIC)
            tname = threading.current_thread()
            print tname
            exportOracleSql = "select 'exp03' from dual"
            print exportOracleSql
            x = cursor.execute(exportOracleSql)
            time.sleep(1000)
            cursor.close()
            conn.close()
    
    def exp04():
            conn = cx_Oracle.connect('system/oracle@192.168.137.2/serv')
            cursor = conn.cursor()
            owner = "system"
            writer = csv.writer(f, lineterminator="
    ", quoting=csv.QUOTE_NONNUMERIC)
            tname = threading.current_thread()
            print tname
            exportOracleSql = "select 'exp04' from dual"
            print exportOracleSql
            x = cursor.execute(exportOracleSql)
            time.sleep(1000)
            cursor.close()
            conn.close()
    
    def exp05():
            conn = cx_Oracle.connect('system/oracle@192.168.137.2/serv')
            cursor = conn.cursor()
            owner = "system"
            writer = csv.writer(f, lineterminator="
    ", quoting=csv.QUOTE_NONNUMERIC)
            tname = threading.current_thread()
            print tname
            exportOracleSql = "select 'exp05' from dual"
            print exportOracleSql
            x = cursor.execute(exportOracleSql)
            time.sleep(1000)
            cursor.close()
            conn.close()
    
    def exp06():
            conn = cx_Oracle.connect('system/oracle@192.168.137.2/serv')
            cursor = conn.cursor()
            owner = "system"
            writer = csv.writer(f, lineterminator="
    ", quoting=csv.QUOTE_NONNUMERIC)
            tname = threading.current_thread()
            print tname
            exportOracleSql = "select 'exp06' from dual"
            print exportOracleSql
            x = cursor.execute(exportOracleSql)
            time.sleep(1000)
            cursor.close()
            conn.close()
    
    def exp07():
            conn = cx_Oracle.connect('system/oracle@192.168.137.2/serv')
            cursor = conn.cursor()
            owner = "system"
            writer = csv.writer(f, lineterminator="
    ", quoting=csv.QUOTE_NONNUMERIC)
            tname = threading.current_thread()
            print tname
            exportOracleSql = "select 'exp07' from dual"
            print exportOracleSql
            x = cursor.execute(exportOracleSql)
            time.sleep(1000)
            cursor.close()
            conn.close()
    
    def exp08():
            conn = cx_Oracle.connect('system/oracle@192.168.137.2/serv')
            cursor = conn.cursor()
            owner = "system"
            writer = csv.writer(f, lineterminator="
    ", quoting=csv.QUOTE_NONNUMERIC)
            tname = threading.current_thread()
            print tname
            exportOracleSql = "select 'exp08' from dual"
            print exportOracleSql
            x = cursor.execute(exportOracleSql)
            time.sleep(1000)
            cursor.close()
            conn.close()
    
    def exp09():
            conn = cx_Oracle.connect('system/oracle@192.168.137.2/serv')
            cursor = conn.cursor()
            owner = "system"
            writer = csv.writer(f, lineterminator="
    ", quoting=csv.QUOTE_NONNUMERIC)
            tname = threading.current_thread()
            print tname
            exportOracleSql = "select 'exp09' from dual"
            print exportOracleSql
            x = cursor.execute(exportOracleSql)
            time.sleep(1000)
            cursor.close()
            conn.close()
    
    def exp10():
            conn = cx_Oracle.connect('system/oracle@192.168.137.2/serv')
            cursor = conn.cursor()
            owner = "system"
            writer = csv.writer(f, lineterminator="
    ", quoting=csv.QUOTE_NONNUMERIC)
            tname = threading.current_thread()
            print tname
            exportOracleSql = "select 'exp10' from dual"
            print exportOracleSql
            x = cursor.execute(exportOracleSql)
            time.sleep(1000)
            cursor.close()
            conn.close()
    
    def exp11():
            conn = cx_Oracle.connect('system/oracle@192.168.137.2/serv')
            cursor = conn.cursor()
            owner = "system"
            writer = csv.writer(f, lineterminator="
    ", quoting=csv.QUOTE_NONNUMERIC)
            tname = threading.current_thread()
            print tname
            exportOracleSql = "select 'exp11' from dual"
            print exportOracleSql
            x = cursor.execute(exportOracleSql)
            time.sleep(1000)
            cursor.close()
            conn.close()
    
    def exp12():
            conn = cx_Oracle.connect('system/oracle@192.168.137.2/serv')
            cursor = conn.cursor()
            owner = "system"
            writer = csv.writer(f, lineterminator="
    ", quoting=csv.QUOTE_NONNUMERIC)
            tname = threading.current_thread()
            print tname
            exportOracleSql = "select 'exp12' from dual"
            print exportOracleSql
            x = cursor.execute(exportOracleSql)
            time.sleep(1000)
            cursor.close()
            conn.close()
    
    def exp13():
            conn = cx_Oracle.connect('system/oracle@192.168.137.2/serv')
            cursor = conn.cursor()
            owner = "system"
            writer = csv.writer(f, lineterminator="
    ", quoting=csv.QUOTE_NONNUMERIC)
            tname = threading.current_thread()
            print tname
            exportOracleSql = "select 'exp13' from dual"
            print exportOracleSql
            x = cursor.execute(exportOracleSql)
            time.sleep(1000)
            cursor.close()
            conn.close()
    
    def exp14():
            conn = cx_Oracle.connect('system/oracle@192.168.137.2/serv')
            cursor = conn.cursor()
            owner = "system"
            writer = csv.writer(f, lineterminator="
    ", quoting=csv.QUOTE_NONNUMERIC)
            tname = threading.current_thread()
            print tname
            exportOracleSql = "select 'exp14' from dual"
            print exportOracleSql
            x = cursor.execute(exportOracleSql)
            time.sleep(1000)
            cursor.close()
            conn.close()
    
    threads = []
    t1 = threading.Thread(target=exp01,name='xxyy11')
    threads.append(t1)
    t2 = threading.Thread(target=exp02,name='xxyy22')
    threads.append(t2)
    t2 = threading.Thread(target=exp03,name='xxyy22')
    threads.append(t2)
    t2 = threading.Thread(target=exp04,name='xxyy22')
    threads.append(t2)
    t2 = threading.Thread(target=exp05,name='xxyy22')
    threads.append(t2)
    t2 = threading.Thread(target=exp06,name='xxyy22')
    threads.append(t2)
    t2 = threading.Thread(target=exp07,name='xxyy22')
    threads.append(t2)
    t2 = threading.Thread(target=exp08,name='xxyy22')
    threads.append(t2)
    t2 = threading.Thread(target=exp09,name='xxyy22')
    threads.append(t2)
    t2 = threading.Thread(target=exp10,name='xxyy22')
    threads.append(t2)
    t2 = threading.Thread(target=exp11,name='xxyy22')
    threads.append(t2)
    t2 = threading.Thread(target=exp12,name='xxyy22')
    threads.append(t2)
    t2 = threading.Thread(target=exp13,name='xxyy22')
    threads.append(t2)
    t2 = threading.Thread(target=exp14,name='xxyy22')
    threads.append(t2)
    
    if __name__ == '__main__':
        for t in threads:
            #t.setDaemon(True)
            t.start()
            #t.run()
            #t.start()
            # print '3333333'
            print threading.current_thread()
            # print t.is_alive()
            # print '3333333'
        t.join()
        print "all over "
    
    

  • 相关阅读:
    如何理解显示卡的驱动模块(DDX,DRM,DRI,XVMC)
    基于Linux的嵌入式文件系统构建与设计
    Windows系统——后缀为.zip.00X的zip分卷解压
    windows系统——U 盘损坏修复
    windows系统——常用命令
    U盘用FAT32还是用NTFS格式好
    linux系统程序设计教程
    Posix线程编程指南
    编程风格——UNIX 高手的 10 个习惯
    linux压缩文件——解压方法
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13349547.html
Copyright © 2011-2022 走看看