summaryrefslogtreecommitdiff
path: root/taskflow/engines/worker_based/executor.py
Commit message (Collapse)AuthorAgeFilesLines
* Remove sixTakashi Kajinami2022-05-181-2/+1
| | | | | | | | This library no longer supports Python 2, thus usage of six can be removed. This also removes workaround about pickle library used in Python 2 only. Change-Id: I19d298cf0f402d65f0b142dea0bf35cf992332a9
* Use a automaton machine for WBE request state machineJoshua Harlow2016-02-211-1/+1
| | | | Change-Id: Ib26ff4418ab1128a578519be964c4d39cbd1d2f4
* Add WBE worker expiryJoshua Harlow2016-02-141-2/+6
| | | | | | | | | When a worker hasn't responded to a notification request for a given amount of time remove it from being a useable worker that we can match task submissions to. Change-Id: I596bccc1c42f83ee79136dd27bc87039154ff7b1
* Some WBE protocol/executor cleanupsJoshua Harlow2016-02-141-14/+18
| | | | | | | | | | | | | | | | | | | Remove some of the usage of @property as none of these objects are publicly exposed (or have docstrings on them) to save some space/lines of code that aren't really adding any benefit. Use less **kwargs when we know exactly what the keyword arguments will or will not be. Being explicit makes it easier to understand these functions (vs not knowing what the arguments can or can't be). Removes base worker finder because right now we only have one implementation (at some point we will have two) but we can just wait to add a base class until then. Change-Id: I7107ff6b77a355b4c5d301948355fb6386605388
* Remove need for separate notify threadJoshua Harlow2016-02-141-23/+36
| | | | | | | | | | | | | | Instead of having a periodic notification thread that will drop messages to try to find workers we can just have this same work be done in the periodically called on_wait callback that is already used for expiring and matching workers to new/updated workers. This avoids having one more thread that doesn't do all that much (and activating it during waiting calls will be often enough to achieve its goal in life). Change-Id: If80233d13d914f2ed3665001a27627b78e6ee780
* Don't bother scanning for workers if no new messages arrivedJoshua Harlow2016-02-111-7/+20
| | | | | | | | | | If the worker finder has not gotten any new notification messages letting it know about new (or updated) workers we can just skip trying to match existing waiting work to workers as without messages being processed the match will still not work (as the worker data doesn't change without those messages being processed). Change-Id: I41d50c676f04f85c49a03d9d503da1955af45f7d
* Fix for WBE sporadic timeout of tasksJoshua Harlow2016-02-051-46/+63
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes the sporadic of tasks that would happen under certain circumstances. What happened was that a new worker notification would be sent to a callback while at the same time a task submission would come in and there would be a small race period where the task would insert itself into the requests cache while the callback was processing. So to work around this the whole concept of a requests cache was revamped and now the WBE executor just maintains its own local dictionary of ongoing requests and accesses it safely. During the on_wait function that is periodically called by kombu the previous expiry of work happens but now any requests that are pending are matched to any new workers that may have appeared. This avoids the race (and ensures that even if a new worker is found but a submission is in progress that the duration until that submission happens will only be until the next on_wait call happens). Related-Bug: #1431097 Change-Id: I98b0caeedc77ab2f7214847763ae1eb0433d4a78
* Make more of the WBE logging and '__repr__' message more usefulJoshua Harlow2015-10-091-2/+2
| | | | | | | | | When running the examples, especially when running them in TRACE/BLATHER/DEBUG logging level these updates make it more clear = what is being processed, the messages being sent/acked/received and what there contents are. Change-Id: I94a497c9064df30197454ae480fe3d471ba1dc7d
* Integrate futurist (and **remove** taskflow originating code)Joshua Harlow2015-07-091-2/+2
| | | | Change-Id: If89baa042695f19e42b6368034f3ccf22c2cf0aa
* Make the dispatcher handler be an actual typeJoshua Harlow2015-02-151-4/+3
| | | | | | | | | | | | | Instead of having the dispatcher target be a tuple or a single callback, have it be an actual type with comments as to what the types fields are and how they are used. This makes it more obvious as to what those fields are and how they are used so that it is easier to understand how the WBE engine and components work. Change-Id: I5541ccd5a7aa6ae73ed9adceeac2c0524e2a1dc9
* Use a notifier instead of a direct property assignmentJoshua Harlow2015-02-041-2/+4
| | | | | | | | | | | | | | To allow for finders to be shared (across executors) in the near future we need to avoid assigning our callback as the sole/single callback that the finder will use and instead use a notification mechanism (using our notifier type) that can be used to register many callbacks and decouple the emitting of new workers events from the reception of that event. Part of blueprint wbe-worker-info Change-Id: I0ab2ec649f759ec67e15960bdeb83b108174734b
* Abstract out the worker finding from the WBE engine0.7.0Joshua Harlow2015-01-311-37/+24
| | | | | | | | | | | | | | To be able to easily plug-in future types of ways to get which topics (and tasks) workers exist on (and can perform) and to identify and keep this information up-to date refactor the functionality that currently does this using periodic messages into a finder type and a periodic function that exists on it (that will be periodically activated by an updated and improved periodic worker). Part of blueprint wbe-worker-info Change-Id: Ib3ae29758af3d244b4ac4624ac380caf88b159fd
* Add and use a nicer kombu message formatterJoshua Harlow2015-01-291-3/+7
| | | | | | | | | | | Since the kombu message object that is recieved has no useful __str__ or __repr__ and on reception and processing we should the message (and the delivery tag) it is nice to have a more useful formatting of that message for debugging and such (where more detail about the messages are quite useful to see). Change-Id: I6730b10122a5de1a0a074525931f312fbd97b8c0
* Add a thread bundle helper utility + testsJoshua Harlow2015-01-241-18/+10
| | | | | | | | | | | | To make it easier to create a bunch of threads in a single call (and stop them in a single call) create a concept of a thread bundle (similar to a thread group) that will call into a provided set of factories to get a thread, activate callbacks to notify others that a thread is about to start or stop and then perform the start or stop of the bound threads in a orderly manner. Change-Id: I7d233cccb230b716af41243ad27220b988eec14c
* Tidy up the WBE cache (now WBE types) moduleJoshua Harlow2015-01-221-67/+23
| | | | | | | | | | | | | | | Instead of using the expiring cache type as a means to store worker information just avoid using that type since we don't support expiry in the first place on worker information and use a worker container and a worker object that we can later extend as needed. Also add on clear methods to the cache type that will be used when the WBE executor stop occurs. This ensures we clear out the worker information and any unfinished requests. Change-Id: I6a520376eff1e8a6edcef0a59f2d8b9c0eb15752
* Use explicit WBE object arguments (instead of kwargs)Joshua Harlow2015-01-221-4/+9
| | | | | | | | | | | | | | Instead of passing around kwargs to root WBE classes and to contained classes prefer to use explicitnamed arguments that are passed around. This makes the code more obvious as to what the intended arguments are and makes it easier for error validation when other unknown arguments are passed (as well as for docs). Also moves the docs for the worker engine to be a sub-TOC under the main engine document so that it can be more easily explored and managed/found... Change-Id: I9413fad187c330fee494f0d4536cc27d9a90f0fb
* Switch to using 'oslo_utils' vs 'oslo.utils'Joshua Harlow2015-01-141-2/+2
| | | | | | | | Prefer the non-deprecated 'oslo_utils' instead of the namespaced 'oslo.utils' wherever it was previously used. Change-Id: I9a78150ef5266e1ff22147278162fe3cfe1b2e3f
* Merge "Get the basics of a process executor working"Jenkins2014-12-201-12/+6
|\
| * Get the basics of a process executor workingJoshua Harlow2014-12-191-12/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since we support various executors (threaded and distributed) the next best executor when a threaded executor will not perform and a distributed one requires to much setup is a local process based one so it would be great to support this where we can. Things that are currently (likely never) not going to work: * Non-pickleable/non-copyable tasks * Tasks that return non-pickleable/non-copyable results * Tasks that use non-pickleable/non-copyable args/kwargs Part of blueprint process-executor Change-Id: I966ae01d390c7217b858db3feb2db949ce5c08d1
* | Move over to using oslo.utils [reflection, uuidutils]Joshua Harlow2014-12-181-1/+1
|/ | | | | | | | | | | | | | The reflection module is now part of oslo.utils so we should remove our local version and use that version instead; this also goes for the uuidutils module which is now part of oslo.utils as well so we no longer need our local version copied from the incubator... Note that one reflection method `find_subclasses` which was to specific to taskflow is now moved to the misc utility module instead of its prior home in the reflection module. Change-Id: I069881c80b0b2916cc0c414992b80171f7eeb79f
* Base task executor should provide 'wait_for_any'Joshua Harlow2014-12-151-5/+0
| | | | | | | | | | | Instead of having each task executor reproduce the same code for 'wait_for_any' we can just have the base task implementation provide the function that everyone is replicating instead; making common code common and save the headache caused by the same code being in multiple places (which is bad for multiple reasons). Change-Id: Icea4b7e3df605ab11b17c248d05acb3f9c02a1ca
* Use the notifier type in the task class/module directlyJoshua Harlow2014-12-131-4/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Instead of having code that is some what like the notifier code we already have, but is duplicated and is slightly different in the task class just move the code that was in the task class (and doing similar actions) to instead now use a notifier that is directly contained in the task base class for internal task triggering of internal task events. Breaking change: alters the capabilities of the task to process notifications itself, most actions now must go through the task notifier property and instead use that (update_progress still exists as a common utility method, since it's likely the most common type of notification that will be used). Removes the following methods from task base class (as they are no longer needed with a notifier attribute): - trigger (replaced with notifier.notify) - autobind (removed, not replaced, can be created by the user of taskflow in a simple manner, without requiring functionality in taskflow) - bind (replaced with notifier.register) - unbind (replaced with notifier.unregister) - listeners_iter (replaced with notifier.listeners_iter) Due to this change we can now also correctly proxy back events from remote tasks to the engine for correct proxying back to the original task. Fixes bug 1370766 Change-Id: Ic9dfef516d72e6e32e71dda30a1cb3522c9e0be6
* Remove the base postfix from the internal task executorJoshua Harlow2014-12-121-1/+1
| | | | | | | | | | There is no need to have a postfix of 'base' in the task executor as it is obvious by having a metaclass of abc.ABCMeta and the fact that it has no methods that the task executor base is a base class and should be used as such without a 'base' postfix to also signify the same information. Change-Id: I1f5cbcd29f1453d68e774f9f9f733eb873efc7cb
* Add and use a new simple helper logging moduleJoshua Harlow2014-12-081-1/+1
| | | | | | | | | Add a new logging BLATHER level to easily allow its usage for messages that are below the normal DEBUG level such as compilation information and scope lookup info which can be very verbose in logs if always enabled. Change-Id: I828211403bd02bfd6777b10cdcfe58fb0637a52c
* Use condition variables using 'with'Joshua Harlow2014-12-081-8/+2
| | | | | | | | | Instead of doing [acquire, try, finally, release] just use the condition variable as a context manager to achieve the same effect with less code and with less verbosity. Change-Id: I0a3bb80a932a3dc6623ba2378afa0341e9e06e5a
* Be explicit about publish keyword argumentsJoshua Harlow2014-12-041-2/+1
| | | | | | | | | Instead of allowing for arbitrary keyword arguments which makes the API hard to change in the future prefer to have explicit arguments (and keyword arguments) instead of allowing **kwargs to be passed. Change-Id: I374db6b19ef76c2f9ee04771f5d928c79b7cf049
* Remove direct usage of the deprecated failure locationJoshua Harlow2014-10-211-3/+3
| | | | | | | | Internally we should be using the new location and not the deprecated location wherever possible. This avoids emitting warnings messages on our own code, which is a dirty habit. Change-Id: Idac5a772eca7529d92542ada3be1cea092880e25
* Adjust the WBE log levelsJoshua Harlow2014-09-271-2/+2
| | | | | | | | | | | | To conform better with the logging level standards move away from using LOG.exception when the level is more appropriately a warning/warn. Also changes how a message that can not be sent is really a critical error and should be treated as such (since such an error affects the overall execution model). Change-Id: I7cebd882b655958d539be36ce3b4deb75ac4a0b7
* Merge "Increase/adjust the logging of the WBE response/send activities"Jenkins2014-09-271-7/+20
|\
| * Increase/adjust the logging of the WBE response/send activitiesJoshua Harlow2014-09-221-7/+20
| | | | | | | | Change-Id: I1d8309ce87114a0890dfc93a0a2c4b68f80ef828
* | Merge "Switch to using oslo.utils and oslo.serialization"Jenkins2014-09-261-1/+2
|\ \ | |/ |/|
| * Switch to using oslo.utils and oslo.serializationJoshua Harlow2014-09-201-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | Instead of copying modules from the incubator into taskflow we can now directly use these same modules from supported libraries instead so this moves the usage of everything except uuidutils which wasn't moved over to using those newly published libraries. Part of blueprint integrate-and-use-oslo-utils-serialization Change-Id: I1183bda96e1ddb062d9cab91990186f0f56f0a0e
* | Merge "Allow WBE request transition timeout to be dynamic"Jenkins2014-09-231-3/+6
|\ \ | |/ |/|
| * Allow WBE request transition timeout to be dynamicJoshua Harlow2014-08-121-3/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | To enable longer (or shorter) timeouts for a WBE submitted request to transition out of the (PENDING, WAITING) states allow the transition timeout that was previously set to 60 seconds to be provided as a WBE configuration option (it still defaults to the previously fixed 60 seconds when it is not provided). Fixes bug 1356002 Change-Id: Idf384217004a334df03e2fff9150309fdfe08005
* | Update transitioning function name to be more understandableJoshua Harlow2014-09-051-7/+7
| | | | | | | | | | | | | | | | To make it more obvious what this function does adjust the naming to be more clear and add a docstring that explains this in more depth. Change-Id: Ib39afd28e0bdeb94d50e85f2a39e210d3cbd7b01
* | Use explicit WBE request state transitionsJoshua Harlow2014-09-041-18/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Instead of having an implicit state machine for a requests lifecycle move toward an explicit state model and transition set that is validated and transitioned in a more easy to understand/reason about manner. This also fixes a bug that was found due to a response validation not taking into account a transition that was found due to this stricter transition checking. Includes a few tiny related/affected commits: * Remove testing of request repr() and str() as these types of tests are not useful and we removed the repr() version of the request message as the base classes is good enough. * Raise and capture a better exception and save its associated failure object when a request has expired (this gives expired requests better failure objects and associated details). Fixes bug 1356658 Partially fixes bug 1357117 Change-Id: Ie1386cca13a2da7265e22447b4c111a0a0074201
* | Avoid naming time type module the same as a builtinJoshua Harlow2014-08-121-1/+1
|/ | | | | | | | | In order to avoid naming conflicts which can easily occur if we name our time module as a python builtin just pick a name that doesn't conflict (it still retains the same meaning). Change-Id: Ia19f3776689d2b1f31f7cbfaa15e53f99a3ee900
* Merge "WBE response message validation"Jenkins2014-08-121-1/+4
|\
| * WBE response message validationJoshua Harlow2014-07-251-1/+4
| | | | | | | | | | | | | | | | | | | | | | Add receive validation of the response message sent by workers for progress updates and for result completion to be more robust around invalid message formats being sent and received. Part of blueprint wbe-message-validation Change-Id: I583b9d6344224724d147f2a5b10ddbd23d6a5fdc
* | Merge "WBE notification message validation"Jenkins2014-08-121-1/+5
|\ \ | |/
| * WBE notification message validationJoshua Harlow2014-07-251-1/+5
| | | | | | | | | | | | | | | | | | | | | | Add send and receive validation of the notify message that is sent between executors and workers to be more robust around invalid message formats being sent and received. Part of blueprint wbe-message-validation Change-Id: I7300d6f2d00e48c4f989c7f958a028bdff4afdd4
* | Improve WBE testing coverageJoshua Harlow2014-07-251-1/+35
|/ | | | | | | | | | | | | Test more of the message pump process and verify that messages are received and sent correctly by using a latch type and waiting for the desired number of messages to be triggered. Test the full server and executor pipeline by setting up threads and a in-memory queue/exchange that is used by these threads for task execution. Change-Id: I62296f12eee6fa00559e84068ec5ee2a6d4bc0dc
* Use a common message dispatcherJoshua Harlow2014-07-251-26/+6
| | | | | | | | | | | | | | | | Instead of recreating a dispatcher in the server and executor objects use a common dispatcher that is shared between them. It will dispatch based on the message type received into a provided dict of dispatch handler callbacks. It also can generically requeue messages and can reject messages if they are missing key required message properties ('type' in the current case). Part of blueprint wbe-message-validation Change-Id: I8320f4707183f36e6a69f0552cf62f99a5467b7e
* Merge "Create a top level time type"Jenkins2014-07-031-1/+2
|\
| * Create a top level time typeJoshua Harlow2014-06-201-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | Create a time module under types and place the stop watch class and timeout classes there so that we can have a single location where generic types that do things with time can be located. Part of blueprint top-level-types Change-Id: I8eb7e897c0354b20a7fa0d061434006e775d5e94
* | Make the expiring cache a top level cache typeJoshua Harlow2014-06-291-7/+6
|/ | | | | | | | | | | | Create a cache module type and adjust a few of its methods to be more pythonic and then switch out the work_based engines usage of it and adjust its tests methods with adjusted methods using the new cache types functionality. Part of blueprint top-level-types Change-Id: I75c4b7db6dd989ef328e9e14d4b00266b1c97a9f
* Upgrade hacking version and fix some of the issuesJoshua Harlow2014-06-131-4/+2
| | | | | | | | | | | | | | | | | Update hacking to the new requirements version and fix about half of the new reported issues. The other hacking issues are for now ignored until fixed by adjusting our tox.ini file. This commit fixes the following new hacking errors: H405 - multi line docstring summary not separated with an empty line E265 - block comment should start with '# ' F402 - import 'endpoint' from line 21 shadowed by loop variable Change-Id: I6bae61591fb988cc17fa79e21cb5f1508d22781c
* Move the daemon thread helper functionJoshua Harlow2014-04-101-11/+3
| | | | | | This function seems better suited in the threading_utils module. Change-Id: Iddd438b57973c7c6c26bd7b6239630656530bd1b
* Create a periodic worker helper classJoshua Harlow2014-04-101-18/+53
| | | | | | | | | | Create a simple class that can call a set of functions periodically and use this in the case where we run a notification thread instead of handling this internally to the worker executor directly. Change-Id: I386e027cf461480799614e20e920b46788f99cab
* Worker executor adjustmentsJoshua Harlow2014-03-311-2/+5
| | | | | | | | | | | | - Reset the notify_timeout on start (to ensure that the notification thread will continue working on repeated stops/starts) - Adjust comment of stop/start method to reflect that more than just the proxy thread is started and stopped. Fixes bug 1300373 Change-Id: I534fa87d9f3b9cfd7aa553f157cb7e776a08f54f