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

Share condition registry & context among threads. #13

Merged
merged 4 commits into from
Jun 2, 2015

Conversation

kadams54
Copy link
Member

@kadams54 kadams54 commented Jun 1, 2015

Turns out some things need to be shared among the threads. To avoid race conditions, these variables should only be populated at server startup; after that, they should be read-only.

@kadams54
Copy link
Member Author

kadams54 commented Jun 1, 2015

QA

Dependencies have changed, so fire up a virtualenv and run pip install -r requirements.txt before starting. You should see Bottle and paste install.

  1. Startup the included server (which is now multi-threaded paste, wrapped by Bottle) by running python example/server.py.
  2. At this point you should be able to hit http://localhost:8080 and see a message about whether the example switch is active or not.
  3. Open a new tab to Switchboard admin, at http://localhost:8080/_switchboard/.
  4. Verify that you can:
    • Add a switch
    • Delete a switch
    • Edit a switch
    • View switch history
    • Change the switch status (with expected results on the switch output displayed at the root)
    • Add/remove conditions from a switch (again, with expected results on the switch output)

@@ -33,7 +37,7 @@ def nested_config(config):
return cfg


def configure(config={}, nested=False):
def configure(config={}, nested=False, request=None, user=None):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The user parameter looks unused and untested.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, honestly, this (passing user and request into configure) is a hack right now, until I can code up a more robust API for defining a context (i.e. the data that a switch has to work with to determine if it should be active). Internally, user (assigned to context['user']) is only used when versioning a switch. Externally, it can be used (as we do) by custom conditions to turn switches on/off for certain users, groups, permissions, etc.

@jrwren
Copy link
Contributor

jrwren commented Jun 1, 2015

👍

@hatched
Copy link

hatched commented Jun 2, 2015

👍 Will QA

@hatched
Copy link

hatched commented Jun 2, 2015

QA OK!

@hatched
Copy link

hatched commented Jun 2, 2015

Not part of this branch but it would be nice if the action icons beside the switch names were bigger with some padding between them.

@kadams54
Copy link
Member Author

kadams54 commented Jun 2, 2015

Thanks all!

@hatched #14

kadams54 added a commit that referenced this pull request Jun 2, 2015
Share condition registry & context among threads.
@kadams54 kadams54 merged commit e56f845 into switchboardpy:master Jun 2, 2015
@kadams54 kadams54 deleted the multithread-fix branch June 2, 2015 16:34
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

Successfully merging this pull request may close these issues.

3 participants