Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use an actions queue instead of a string #3

Closed
0xjac opened this issue Jun 23, 2017 · 2 comments
Closed

Use an actions queue instead of a string #3

0xjac opened this issue Jun 23, 2017 · 2 comments

Comments

@0xjac
Copy link

0xjac commented Jun 23, 2017

Use a Queue rather than a string to handle the actions may be more adapted (L118)

It's clearer and you can get rid of ACTION_SIZE and i logic.

Here is an example on how you would handle it:

from queue import Queue


def __init__(self, *args, **kwargs):
    self.actions = Queue()

def do_actions(self):
    while not self.actions.empty():
        action = self.actions.get()
        # do something with action
        
def add_action(action):
    self.actions.put(action)  # instead of self.actions += action

This is also much easier to make thread-proof in the future, when you have ATMs with octo-cores... 😁

@0xjac 0xjac mentioned this issue Jun 23, 2017
@tshabs
Copy link

tshabs commented Jun 24, 2017

Note on using Queue, it might be better to use six.moves Queue (for py2 & py3 compatibility).

eg:
rtu-dataframe/escposprinter@4e13ee2

@0xjac
Copy link
Author

0xjac commented Jun 25, 2017

I wasn't aware you needed compatibility with Python 2. In that case, yes use six.moves.

Using Enum in #4 may also be problematic. I would write a simple Enum class for Python 2 in this case.

Minege added a commit that referenced this issue Jun 27, 2017
@Minege Minege closed this as completed in cc5ff6d Jul 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants