Comments (9)
Correct me if I'm wrong but you want to have something like this:
create_namespaced_pod("pod-1", "ns-1", cb_success, cb_error)
create_namespaced_pod("pod-2", "ns-2", cb_success, cb_error)
so instead of using async_req
i suggest you implement it in this way (draft):
def cb_helper(func_name, cb_success, cb_error, *args, **kwargs):
try:
result = func_name(*args, **kwargs)
except Exception as ex:
cb_error(ex)
cb_success(result)
pool = with ThreadPool()
pool.apply_async(cb_helper, create_namespaced_pod, "pod-1", "ns-1", cb_success, cb_error)
pool.apply_async(cb_helper, create_namespaced_pod, "pod-2", "ns-2", cb_success, cb_error)
....
....
so it uses synchronous requests but from threads so main thread is not blocked...
from python.
I would like to submit the PR if we align on this.
from python.
Upstream Kubernetes API doesn't support such callback mechanism AFAICT. Could you check with the upstream on this feature request?
from python.
@roycaihw
Async calls are submitted through python thread pool. Python thread pool does support callbacks.
Check api_client.py for the same
if not async_req:
return self.__call_api(resource_path, method,
path_params, query_params, header_params,
body, post_params, files,
response_type, auth_settings,
_return_http_data_only, collection_formats,
_preload_content, _request_timeout, _host)
return self.pool.apply_async(self.__call_api, (resource_path,
method, path_params,
query_params,
header_params, body,
post_params, files,
response_type,
auth_settings,
_return_http_data_only,
collection_formats,
_preload_content,
_request_timeout,
_host))
from python.
CC @tomplus Could you take a look?
from python.
apply_async
returns AsyncResult so as you've written it doesn't support callbacks. These functions are auto-generated by OpenAPI Generator so it's not easy to introduce such change.
I can suggest using sync api calls but from a dedicated thread pool where you can add callbacks as you need. What do you think?
from python.
@tomplus
We were avoiding the synchronous requests due to performance reasons. It would be great if we make the requests asyncronous with callbacks support.
from python.
Marking this as resolved. Please let us know if you have more questions
/close
from python.
@roycaihw: Closing this issue.
In response to this:
Marking this as resolved. Please let us know if you have more questions
/close
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.
from python.
Related Issues (20)
- Test 1
- K8s Python interface issue HOT 2
- Manage resourceVersion to allow resilient restart of watch method HOT 2
- [stream/ws_client] Reading long stdout is truncated at 32768 chars HOT 3
- Request timeout in APIs HOT 9
- Watch() returns wrong "DELETED" event HOT 2
- Version 30.0? HOT 6
- Failed to create deployment HOT 2
- How to get access to the slack channel? HOT 2
- Watch stream missing job completion events HOT 1
- `KubeConfigMerger` object poorly structured when `KUBECONFIG` is a list of files. HOT 2
- Cannot change kube config at runtime HOT 4
- k8s_sdk29.0 error:no attribute 'BatchV1beta1Api' HOT 2
- Support new Kubernetes Sidecar Containers HOT 2
- When I call the query deployment interface, it returns 403 forbidden. HOT 1
- Make google-auth an optional dependency
- kubernetes.client.AuthenticationV1TokenRequest() fails HOT 1
- Allow utils.create_from_yaml to use server side apply
- Error with api when set configuration assert_hostname as true
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python.