Когда я использую потоки для выполнения salt.client.get_local_client() и одновременно вызываю функцию cmd(), я получаю ошибку об отсутствии цикла событий в потоке. Я не уверен, связана ли проблема с моим подходом или с дизайном самой соли.
python test.py
Exception in thread Thread-2:
Traceback (most recent call last):
Exception in thread Thread-1:
File "/home/test/.pyenv/versions/test/lib/python3.9/site-packages/salt/client/__init__.py", line 387, in run_job
Traceback (most recent call last):
File "/home/test/.pyenv/versions/test/lib/python3.9/site-packages/salt/client/__init__.py", line 387, in run_job
pub_data = self.pub(
File "/home/test/.pyenv/versions/test/lib/python3.9/site-packages/salt/client/__init__.py", line 1898, in pub
pub_data = self.pub(
File "/home/test/.pyenv/versions/test/lib/python3.9/site-packages/salt/client/__init__.py", line 1898, in pub
with salt.channel.client.ReqChannel.factory(
File "/home/test/.pyenv/versions/test/lib/python3.9/site-packages/salt/channel/client.py", line 56, in factory
with salt.channel.client.ReqChannel.factory(
return SyncWrapper(
File "/home/test/.pyenv/versions/test/lib/python3.9/site-packages/salt/channel/client.py", line 56, in factory
File "/home/test/.pyenv/versions/test/lib/python3.9/site-packages/salt/utils/asynchronous.py", line 76, in __init__
return SyncWrapper(
File "/home/test/.pyenv/versions/test/lib/python3.9/site-packages/salt/utils/asynchronous.py", line 76, in __init__
self.obj = cls(*args, **kwargs)
File "/home/test/.pyenv/versions/test/lib/python3.9/site-packages/salt/channel/client.py", line 138, in factory
self.obj = cls(*args, **kwargs)
File "/home/test/.pyenv/versions/test/lib/python3.9/site-packages/salt/channel/client.py", line 138, in factory
transport = salt.transport.request_client(opts, io_loop=io_loop)
File "/home/test/.pyenv/versions/test/lib/python3.9/site-packages/salt/transport/base.py", line 59, in request_client
transport = salt.transport.request_client(opts, io_loop=io_loop)
File "/home/test/.pyenv/versions/test/lib/python3.9/site-packages/salt/transport/base.py", line 59, in request_client
return salt.transport.zeromq.RequestClient(opts, io_loop=io_loop)
File "/home/test/.pyenv/versions/test/lib/python3.9/site-packages/salt/transport/zeromq.py", line 1084, in __init__
return salt.transport.zeromq.RequestClient(opts, io_loop=io_loop)
File "/home/test/.pyenv/versions/test/lib/python3.9/site-packages/salt/transport/zeromq.py", line 1084, in __init__
self.sending = asyncio.Lock()
File "/home/test/.pyenv/versions/3.9.18/lib/python3.9/asyncio/locks.py", line 81, in __init__
self.sending = asyncio.Lock()
File "/home/test/.pyenv/versions/3.9.18/lib/python3.9/asyncio/locks.py", line 81, in __init__
self._loop = events.get_event_loop()
File "/home/test/.pyenv/versions/3.9.18/lib/python3.9/asyncio/events.py", line 642, in get_event_loop
self._loop = events.get_event_loop()
File "/home/test/.pyenv/versions/3.9.18/lib/python3.9/asyncio/events.py", line 642, in get_event_loop
raise RuntimeError('There is no current event loop in thread %r.'
RuntimeError: There is no current event loop in thread 'Thread-2'.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/test/.pyenv/versions/3.9.18/lib/python3.9/threading.py", line 980, in _bootstrap_inner
raise RuntimeError('There is no current event loop in thread %r.'
RuntimeError: There is no current event loop in thread 'Thread-1'.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/test/.pyenv/versions/3.9.18/lib/python3.9/threading.py", line 980, in _bootstrap_inner
self.run()
File "/home/test/.pyenv/versions/3.9.18/lib/python3.9/threading.py", line 917, in run
self.run()
File "/home/test/.pyenv/versions/3.9.18/lib/python3.9/threading.py", line 917, in run
self._target(*self._args, **self._kwargs)
File "/home/test/test.py", line 9, in test_sleep
self._target(*self._args, **self._kwargs)
cl.cmd('master-local', 'test.sleep', [2])
File "/home/test/test.py", line 9, in test_sleep
File "/home/test/.pyenv/versions/test/lib/python3.9/site-packages/salt/client/__init__.py", line 752, in cmd
cl.cmd('master-local', 'test.sleep', [2])
File "/home/test/.pyenv/versions/test/lib/python3.9/site-packages/salt/client/__init__.py", line 752, in cmd
pub_data = self.run_job(
File "/home/test/.pyenv/versions/test/lib/python3.9/site-packages/salt/client/__init__.py", line 409, in run_job
pub_data = self.run_job(
File "/home/test/.pyenv/versions/test/lib/python3.9/site-packages/salt/client/__init__.py", line 409, in run_job
raise SaltClientError(general_exception)
salt.exceptions.SaltClientError: There is no current event loop in thread 'Thread-2'.
raise SaltClientError(general_exception)
salt.exceptions.SaltClientError: There is no current event loop in thread 'Thread-1'.
from threading import Thread
import salt.client
import time
cl = salt.client.get_local_client()
def test_sleep():
cl.cmd('master-local', 'test.sleep', [2])
t1 = Thread(target=test_sleep)
t2 = Thread(target=test_sleep)
t1.start()
# time.sleep(1) #
Как я могу правильно достичь одновременных вызовов, используя потоки с помощью API клиента Salt? Это ограничение в дизайне Salt, или что -то не так с моей реализацией?
Подробнее здесь: [url]https://stackoverflow.com/questions/79388267/when-i-use-threads-to-execute-the-salt-agent-api-i-always-get-an-error-runtimee[/url]
Когда я использую потоки для выполнения salt.client.get_local_client() и одновременно вызываю функцию cmd(), я получаю ошибку об отсутствии цикла событий в потоке. Я не уверен, связана ли проблема с моим подходом или с дизайном самой соли. [code] python test.py Exception in thread Thread-2: Traceback (most recent call last): Exception in thread Thread-1: File "/home/test/.pyenv/versions/test/lib/python3.9/site-packages/salt/client/__init__.py", line 387, in run_job Traceback (most recent call last): File "/home/test/.pyenv/versions/test/lib/python3.9/site-packages/salt/client/__init__.py", line 387, in run_job pub_data = self.pub( File "/home/test/.pyenv/versions/test/lib/python3.9/site-packages/salt/client/__init__.py", line 1898, in pub pub_data = self.pub( File "/home/test/.pyenv/versions/test/lib/python3.9/site-packages/salt/client/__init__.py", line 1898, in pub with salt.channel.client.ReqChannel.factory( File "/home/test/.pyenv/versions/test/lib/python3.9/site-packages/salt/channel/client.py", line 56, in factory with salt.channel.client.ReqChannel.factory( return SyncWrapper( File "/home/test/.pyenv/versions/test/lib/python3.9/site-packages/salt/channel/client.py", line 56, in factory File "/home/test/.pyenv/versions/test/lib/python3.9/site-packages/salt/utils/asynchronous.py", line 76, in __init__ return SyncWrapper( File "/home/test/.pyenv/versions/test/lib/python3.9/site-packages/salt/utils/asynchronous.py", line 76, in __init__ self.obj = cls(*args, **kwargs) File "/home/test/.pyenv/versions/test/lib/python3.9/site-packages/salt/channel/client.py", line 138, in factory self.obj = cls(*args, **kwargs) File "/home/test/.pyenv/versions/test/lib/python3.9/site-packages/salt/channel/client.py", line 138, in factory transport = salt.transport.request_client(opts, io_loop=io_loop) File "/home/test/.pyenv/versions/test/lib/python3.9/site-packages/salt/transport/base.py", line 59, in request_client transport = salt.transport.request_client(opts, io_loop=io_loop) File "/home/test/.pyenv/versions/test/lib/python3.9/site-packages/salt/transport/base.py", line 59, in request_client return salt.transport.zeromq.RequestClient(opts, io_loop=io_loop) File "/home/test/.pyenv/versions/test/lib/python3.9/site-packages/salt/transport/zeromq.py", line 1084, in __init__ return salt.transport.zeromq.RequestClient(opts, io_loop=io_loop) File "/home/test/.pyenv/versions/test/lib/python3.9/site-packages/salt/transport/zeromq.py", line 1084, in __init__ self.sending = asyncio.Lock() File "/home/test/.pyenv/versions/3.9.18/lib/python3.9/asyncio/locks.py", line 81, in __init__ self.sending = asyncio.Lock() File "/home/test/.pyenv/versions/3.9.18/lib/python3.9/asyncio/locks.py", line 81, in __init__ self._loop = events.get_event_loop() File "/home/test/.pyenv/versions/3.9.18/lib/python3.9/asyncio/events.py", line 642, in get_event_loop self._loop = events.get_event_loop() File "/home/test/.pyenv/versions/3.9.18/lib/python3.9/asyncio/events.py", line 642, in get_event_loop raise RuntimeError('There is no current event loop in thread %r.' RuntimeError: There is no current event loop in thread 'Thread-2'.
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/home/test/.pyenv/versions/3.9.18/lib/python3.9/threading.py", line 980, in _bootstrap_inner raise RuntimeError('There is no current event loop in thread %r.' RuntimeError: There is no current event loop in thread 'Thread-1'.
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/home/test/.pyenv/versions/3.9.18/lib/python3.9/threading.py", line 980, in _bootstrap_inner self.run() File "/home/test/.pyenv/versions/3.9.18/lib/python3.9/threading.py", line 917, in run self.run() File "/home/test/.pyenv/versions/3.9.18/lib/python3.9/threading.py", line 917, in run self._target(*self._args, **self._kwargs) File "/home/test/test.py", line 9, in test_sleep self._target(*self._args, **self._kwargs) cl.cmd('master-local', 'test.sleep', [2]) File "/home/test/test.py", line 9, in test_sleep File "/home/test/.pyenv/versions/test/lib/python3.9/site-packages/salt/client/__init__.py", line 752, in cmd cl.cmd('master-local', 'test.sleep', [2]) File "/home/test/.pyenv/versions/test/lib/python3.9/site-packages/salt/client/__init__.py", line 752, in cmd pub_data = self.run_job( File "/home/test/.pyenv/versions/test/lib/python3.9/site-packages/salt/client/__init__.py", line 409, in run_job pub_data = self.run_job( File "/home/test/.pyenv/versions/test/lib/python3.9/site-packages/salt/client/__init__.py", line 409, in run_job raise SaltClientError(general_exception) salt.exceptions.SaltClientError: There is no current event loop in thread 'Thread-2'. raise SaltClientError(general_exception) salt.exceptions.SaltClientError: There is no current event loop in thread 'Thread-1'. [/code] Ниже приведен мой тестовый код [code]from threading import Thread
t1.start() # time.sleep(1) # Как я могу правильно достичь одновременных вызовов, используя потоки с помощью API клиента Salt? Это ограничение в дизайне Salt, или что -то не так с моей реализацией?
Когда я использую потоки для выполнения salt.client.get_local_client() и одновременно вызываю функцию cmd(), я получаю ошибку об отсутствии цикла событий в потоке. Я не уверен, связана ли проблема с моим подходом или с дизайном самой соли.
Когда я использую потоки для выполнения salt.client.get_local_client () и одновременно вызову функцию cmd (), я получаю ошибку об отсутствии цикла событий в потоке. Я не уверен, заключается ли проблема с моим подходом или дизайном самой соли....
Я использую флаттер в коде VS
при запуске «build ipa»
я постоянно получаю эту ошибку
Error (Xcode): No profiles for 'com.mychatapp.ChatApp' were found: Xcode couldn't find any iOS
App Development provisioning profiles matching...
Мне нужно получить возрастной диапазон из Facebook.
Когда я использую /me?fields=age_range в своем GraphRequest .newGraphPathRequest я получаю сообщение об ошибке.
Ошибка заключается в том, чтоgraphObject возвращает значение null. Я пробовал...