-
Notifications
You must be signed in to change notification settings - Fork 0
/
start.py
39 lines (31 loc) · 1.04 KB
/
start.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
#coding: utf8
from ReceiveMessageFromQueue import ReceiveMessage
from thread import start_new
from CustomerTable import CustomerTable
from OrderTable import OrderTable
import time, json
def getMessage(delay):
while True:
messages = ReceiveMessage().message()
for message in messages:
data = json.loads(message.message_text)
if data.get("What")=="Customer":
CustomerTable().insert(data.get("ID"),
data.get("Name"),
data.get("Country"),
data.get("City"))
elif data.get("What")=="Order":
OrderTable().insert(data.get("ID"),
data.get("CustomerID"),
data.get("ProductID"),
data.get("Datetime"),
data.get("TotalPrice"))
print(data)
try:
start_new(getMessage,(0.01,))
#start_new(CustomerTable().listAll,())
except:
print "Error: unable to start thread"
#OrderTable().listAll()
while 1:
pass