swiftly.concurrency

Concurrency API for Swiftly.

Copyright 2011-2013 Gregory Holt

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

class swiftly.concurrency.Concurrency(concurrency=10)[source]

Bases: object

Convenience class to support concurrency, if Eventlet is available; otherwise it just performs at single concurrency.

Parameters:concurrency – The level of concurrency desired. Default: 10
get_results()[source]

Returns a dict of the results currently available. The keys are the ident values given with the calls to spawn. The values are the return values of the funcs.

join()[source]

Blocks until all currently pending functions have finished.

spawn(ident, func, *args, **kwargs)[source]

Returns immediately to the caller and begins executing the func in the background. Use get_results and the ident given to retrieve the results of the func.

Parameters:
  • ident – An identifier to find the results of the func from get_results. This identifier can be anything unique to the Concurrency instance.
  • func – The function to execute in the concurrently.
  • args – The args to give the func.
  • kwargs – The keyword args to the give the func.
Returns:

None

Previous topic

swiftly.client

This Page