-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTheGame.py
61 lines (43 loc) · 1.5 KB
/
TheGame.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
import multiprocessing as mp
from datetime import datetime as dt
import logging
import logbook.log_configuration # Singleton via Import
import database.main_database as db
import controller.model_fabric_new as mf
import controller.viewmodel_fabric as vf
import view.basic_view as vwf
# Starting Time Stamp
start = dt.now()
# Init Database
database = db.Database
# main thread logger
log = logging.getLogger('view')
log.critical('Starting -- %s' % start)
log.info('Creating Connections')
model_connection = mp.Pipe()
view_connection = mp.Pipe()
log.info('Initialize Model Producer')
modelProducer = mf.ModelHandler(database, model_connection[0])
log.info('Initialize ViewModel Producer')
viewmodelProducer = vf.ViewModelProducer(model_connection[1], view_connection[0])
log.info('Init View')
view = vwf.View(database)
if __name__ == '__main__':
log.info('Start Model Producer')
modelProducer.start()
log.info('Start ViewModel Producer')
viewmodelProducer.startProducing()
players_choice = True
while players_choice is not None:
log.info('Get View Model')
view_model = view_connection[1].recv()
log.info('Show View Model')
players_choice = view(view_model)
log.info('Sending %s' % players_choice)
view_connection[1].send(players_choice)
# Clean Up
log.info('Killing ViewModel Producer')
viewmodelProducer.stopProducing()
log.info('Killing Model Producer')
modelProducer.join()
log.info('Done. Session %s' % (dt.now() - start))