mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 05:51:15 +02:00
Fix issue with asyncio.Queue which is not thread safe.
This commit is contained in:
2 files changed
+8
-6
No files matched your search
@@ -15,7 +15,7 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
import asyncio
|
||||
from contextlib import contextmanager
|
||||
from gns3server.utils.notification_queue import NotificationQueue
|
||||
|
||||
@@ -28,6 +28,7 @@ class NotificationManager:
|
||||
|
||||
def __init__(self):
|
||||
self._listeners = set()
|
||||
self._loop = asyncio.get_event_loop()
|
||||
|
||||
@contextmanager
|
||||
def queue(self):
|
||||
@@ -54,7 +55,7 @@ class NotificationManager:
|
||||
"""
|
||||
|
||||
for listener in self._listeners:
|
||||
listener.put_nowait((action, event, kwargs))
|
||||
self._loop.call_soon_threadsafe(listener.put_nowait, (action, event, kwargs))
|
||||
|
||||
@staticmethod
|
||||
def reset():
|
||||
|
||||
Reference in new issue
Block a user