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

Integrating Semaphores into Executor #31

Merged
merged 7 commits into from
Jul 26, 2016
Merged

Conversation

kyleknap
Copy link
Contributor

In order to support the SlidingWindowSemaphore and fix #20, I decided to rip out the current implementation on how we bound the executors and replace it with a semaphore approach.

The PR builds off of: #30. You can look at that one or look at both of the PR's via this one.

The larger changes in this PR include:

  • Add a unique identifier for each transfer request.
  • Instead of relying on current.futures.wait to wait for futures to complete we use semaphores to bound the limits.

cc @jamesls @JordonPhillips

@@ -78,8 +78,9 @@ def cancel(self):

class TransferMeta(object):
"""Holds metadata about the TransferFuture"""
def __init__(self, call_args=None):
def __init__(self, call_args=None, id=None):
Copy link
Contributor

Choose a reason for hiding this comment

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

This shadow's the built-in id.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It should not be an issue because it is isolated to the class but I can update it to something more explicit.

@JordonPhillips
Copy link
Contributor

I don't see any major issues, though I think @jamesls should have a look.

@kyleknap
Copy link
Contributor Author

Alright I updated the code based on feedback. Let me know what you think.

"""
self._semaphore = threading.Semaphore(count)

def acquire(self, tag, blocking=True):
Copy link
Member

Choose a reason for hiding this comment

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

Probably worth documenting/commenting the reason there's params that are required but not used is because we want to be API compatible with the SlidingWindowSemaphore.

@jamesls
Copy link
Member

jamesls commented Jul 22, 2016

:shipit: Looks good to me.

This makes it easier to track the submission of tasks as it relates to
a specific transfer request and makes it easier for tracking requests from
a subscriber.
Refactored interface for BoundedExecutors to be less general.
Adds consistency with Task and avoids confusion with shadowing builtin id.
When result() is called there is no guarantee that the semaphore is released
because it is part of a done callback. As a result, submission would sometimes
happen before the semaphore being released causing random failures
@kyleknap
Copy link
Contributor Author

kyleknap commented Jul 22, 2016

I updated the docstring. @JordonPhillips let me know if you have anymore comments.

@JordonPhillips
Copy link
Contributor

@kyleknap kyleknap merged commit a2730af into boto:develop Jul 26, 2016
@kyleknap kyleknap deleted the semaphore-v2 branch July 26, 2016 06:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Submission thread seems to block on unrelated tags
3 participants