-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
93 lines (75 loc) · 1.75 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import urllib
import os
import sys
import getopt
import os.path
import re
import httplib
import threading
import subprocess
import time
ggg = 56
class abc(object):
"""
"""
__a = 3
b = 9
__mutex = threading.Lock()
def th(self):
print self.__a
pool = []
for i in range(2):
th1 = threading.Thread(target=self.run, args=[str(i)])
pool.append(th1)
th1.start()
for i in range(2):
pool[i].join()
print ' ok'
def run(self, name):
for i in range(10):
self.__mutex.acquire()
self.__a += 1
print ' %s %s' % (name, self.__a)
self.__mutex.release()
def ex(self):
global __a
print ggg
def stop(self):
print self.b
print self.__a
def __init__(self):
pass
#print 'class'
#print sys.argv[:]
# print self.__a
# print self.__class__.__a
# print self.b
# print self.__class__.b
if __name__ == '__main__':
c = abc()
c.stop()
#for i in range(10000):
# try:
# time.sleep(1)
# print ' loop %s ' % i
# except KeyboardInterrupt:
# print ' ctrl-c'
# break
#print ' exit'
#sys.exit(0)
#opts, args = getopt.getopt(sys.argv[1:], "t:m:n:h",['help'])
#print opts
#print args
#for a in args:
# if a not in ('-t','-m','-n','-h','--help'):
# print ' str help'
# sys.exit(1)
#for op, value in opts:
# if op not in ('-t','-m','-n','-h','--help'):
# print op
# print 'str help'
# sys.exit(1)
# else:
# print 'ok'