-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathThread.py
More file actions
43 lines (35 loc) · 1.02 KB
/
Copy pathThread.py
File metadata and controls
43 lines (35 loc) · 1.02 KB
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
#!/usr/bin/python
#encoding=utf-8
import os
import sys
import time
import datetime
import logging
import redis
import threading
import time
import redis
#import db_conf
class GPSThread(threading.Thread):
def __init__(self, thread_id, queue, mutex, logger):
super(GPSThread, self).__init__()
self.thread_id = thread_id
self.queue = queue
self.mutex = mutex
self.logger = logger
def run(self):
#print 'thread[{0}] connect res!!!'.format(self.thread_id)
while True:
if len(self.queue) <= 0:
time.sleep(0.01)
continue
print 'thread[{0}] get requests!!!'.format(self.thread_id)
self.mutex.acquire()
record = self.queue.pop(0)
self.mutex.release()
ret = self.process_record(record)
if ret is False:
print 'error process record!!! data[{0}]'.format(record.data)
continue
def process_record(self, record):
return True