This is an automated email from the ASF dual-hosted git repository.
dinglei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/rocketmq-client-python.git
The following commit(s) were added to refs/heads/master by this push:
new d074515 Add a multi-thread producer test case (#102)
d074515 is described below
commit d074515b0104354d1b54ad53a110e49413f8d889
Author: messense <[email protected]>
AuthorDate: Tue Dec 1 16:56:03 2020 +0800
Add a multi-thread producer test case (#102)
---
dev-requirements.txt | 1 +
tests/test_producer.py | 11 +++++++++++
2 files changed, 12 insertions(+)
diff --git a/dev-requirements.txt b/dev-requirements.txt
index 08d8b97..c96c923 100644
--- a/dev-requirements.txt
+++ b/dev-requirements.txt
@@ -17,3 +17,4 @@ pytest
pytest-timeout
pytest-faulthandler
pytest-cov
+futures; python_version < '3'
diff --git a/tests/test_producer.py b/tests/test_producer.py
index ee71ac8..311bf71 100644
--- a/tests/test_producer.py
+++ b/tests/test_producer.py
@@ -16,6 +16,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
+from concurrent.futures import ThreadPoolExecutor
import time
import threading
import sys
@@ -34,6 +35,16 @@ def test_producer_send_sync(producer):
assert ret.status == SendStatus.OK
+def test_producer_send_sync_multi_thread(producer):
+ executor = ThreadPoolExecutor(max_workers=5)
+ futures = []
+ for _ in range(5):
+ futures.append(executor.submit(test_producer_send_sync, producer))
+
+ for future in futures:
+ _ret = future.result()
+
+
def test_producer_send_oneway(producer):
msg = Message('test')
msg.set_keys('send_oneway')