ServerPortfolio  2.0
Python parsers and server
 All Classes Namespaces Files Functions Variables Properties Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
serverportfolio.Validation.ManagerTk Class Reference

Manage and serialize the access to a ValidationTkinter application, necessary when UpdateStock is run with multiple threads. More...

Public Member Functions

def __init__
 Constructor. More...
 
def update_me
 Check regularly and indefinitely, the queue. More...
 
Queue functions, to be called by threads
def write
 Write a new input to the queue. More...
 
def read_answer
 Return the updated dict_interactive. More...
 

Public Attributes

 queue
 Queue to receive and send data (dict_interactive and stock symbol). More...
 
 queue_answer
 new result data. More...
 

Private Member Functions

def _check_stop
 Check state of the object before stopping. More...
 

Private Attributes

 _logger_
 
 _root_tk
 store a Tk main environment. More...
 

Detailed Description

Manage and serialize the access to a ValidationTkinter application, necessary when UpdateStock is run with multiple threads.

Warning
The object must be created and run from the main thread (tkinter multi-thread limitation)

Interface to ValidationTkinter which assures serialization and thread-safety. The input dict_interactive are treated entry by entry, from an input queue and returned in an output queue. Two GUI cannot exist at the same time. The answer queue should never contain more than 1 entry.
Data are exchanged by the use of Queue for the serialization.
Usage, see main section:

1 # create the object
2 manager = ManagerTk()
3 # run a pool of threads aware of manager. Inside the function a stop signal ['QUIT'] will be send to the manager queue when all thread joined.
4 thd_pool_run( list_stock, manager )
5 
6 # manager enters an infinite loop, and blocks at this line
7 manager.update_me()
8 
9 # from the threads send and receive data
10 manager.write( [stock_symbol], dict_interactive )
11 new_dict_interactive = manager.read()
12 # continue post-process...
Attention
The answer queue should never contain more than 1 entry.
Note
In this version a new tk application is recreated each time. Later one unique Tk widget could be updated.

Definition at line 346 of file Validation.py.

Constructor & Destructor Documentation

def serverportfolio.Validation.ManagerTk.__init__ (   self)

Constructor.

Definition at line 349 of file Validation.py.

Member Function Documentation

def serverportfolio.Validation.ManagerTk._check_stop (   self)
private

Check state of the object before stopping.

Definition at line 410 of file Validation.py.

Referenced by serverportfolio.Validation.ManagerTk.update_me().

Here is the caller graph for this function:

def serverportfolio.Validation.ManagerTk.read_answer (   self)

Return the updated dict_interactive.

Returns
modified dict interactive

Definition at line 374 of file Validation.py.

def serverportfolio.Validation.ManagerTk.update_me (   self)

Check regularly and indefinitely, the queue.

This function is blocking.
To stop the Manager, send the message : ['QUIT'].

Definition at line 387 of file Validation.py.

References serverportfolio.Validation.ManagerTk._check_stop(), and serverportfolio.Validation.ManagerTk._root_tk.

Here is the call graph for this function:

def serverportfolio.Validation.ManagerTk.write (   self,
  new_entry 
)

Write a new input to the queue.

new_entry must be a list, send ['QUIT'] to stop the manager

Parameters
new_entrylist with format : ['stock_symbol',dict_interactive]

Definition at line 370 of file Validation.py.

Member Data Documentation

serverportfolio.Validation.ManagerTk._logger_
private

Definition at line 350 of file Validation.py.

serverportfolio.Validation.ManagerTk._root_tk
private

store a Tk main environment.

Definition at line 362 of file Validation.py.

Referenced by serverportfolio.Validation.ManagerTk.update_me().

serverportfolio.Validation.ManagerTk.queue

Queue to receive and send data (dict_interactive and stock symbol).

new data to be processed

Definition at line 355 of file Validation.py.

serverportfolio.Validation.ManagerTk.queue_answer

new result data.

The caller should get the result before a next entry.

Todo:
to make more secure, a Pipe ?

Definition at line 359 of file Validation.py.


The documentation for this class was generated from the following file: