Comments (3)
- This function is used to generate a unique nonce value for the openapi call, and we don't limit the format to satisfy the uuid. For the historical reasons, the function name may be confusing to readers.
- This is a Python2 repository. Due to python GIL, only one thread can be run. If this GIL assumption does not hold, the randNum field can be used to reduce the collision rate.
- We have tested the this design in tea-util in the real environment, we found that the collisions has been significantly reduced.
from aliyun-openapi-python-sdk.
Thank you for referring aliyun/tea-util#335 and the test results in production environments, though there's a minor issue with Python implementation (compared with Java/Golang implementation of same algorithm):
Due to python GIL, only one thread can be run.
A += 1
in Python would be compiled to multiple bytecodes (load, +=
and store):
>>> n = 0
>>> def f():
... global n
... n += 1
...
>>> import dis
>>> dis.dis(f)
1 0 RESUME 0
3 2 LOAD_GLOBAL 0 (n)
14 LOAD_CONST 1 (1)
16 BINARY_OP 13 (+=)
20 STORE_GLOBAL 0 (n)
22 LOAD_CONST 0 (None)
24 RETURN_VALUE
And in Python 3, GIL would be taken by another thread if it has timed out (https://github.com/python/cpython/blob/65c285062ce2769249610348636d3d73153e0144/Python/ceval_gil.c#L20-L24C58. GIL is also preemptive in Python 2.x), thus n
here is not an atomic variable. And unfortunately Python does not have built-in modules about atomics...
from aliyun-openapi-python-sdk.
感谢 @taoky 对这个改动的关注。作为生成 Nonce 的实现,目前看下来还是 OK 的。这个讨论就暂时先关掉了。
如果还有其余问题,请 re-open。
from aliyun-openapi-python-sdk.
Related Issues (20)
- SDK Support for DescribeAgentInstallStatus() function
- Could you please bump `jmespath` to some newer version? HOT 1
- aliyun-sdk-core doesn't work with crpythongraphy
- aliyun-python-sdk-core apsara protocol type bug HOT 1
- 我是Python3 安装 缺少 [v20180510] HOT 5
- 云监控 DescribeMetricListRequest 接口超时 HOT 1
- asfdf
- code example运行出错
- Project dependencies. HOT 2
- InvalidNetworkType when executing codes generated from "Preview -> View Open API" HOT 1
- CVE for included urllib3 HOT 3
- Can't override default region for DescribeDBInstancesRequest
- Vendored six package is incompatible with Python 3.12.
- Update aliyun-python-sdk-core.vendored.requests: 'cgi' is deprecated and slated for removal in Python 3.13 HOT 3
- aliyun-python-sdk-core can not install HOT 2
- python3.12 support HOT 6
- Protecode security issue on aliyun-python-sdk-core dependency HOT 1
- python3.12环境,aliyun-python-sdk-core(2.14.0)报错:ModuleNotFoundError,请求支持!
- 调用请求 报 product 找不到 HOT 1
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 aliyun-openapi-python-sdk.