pymud 0.19.2.post1__py3-none-any.whl → 0.19.2.post2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pymud/objects.py +6 -4
- pymud/session.py +10 -6
- {pymud-0.19.2.post1.dist-info → pymud-0.19.2.post2.dist-info}/LICENSE.txt +674 -674
- {pymud-0.19.2.post1.dist-info → pymud-0.19.2.post2.dist-info}/METADATA +4 -1
- {pymud-0.19.2.post1.dist-info → pymud-0.19.2.post2.dist-info}/RECORD +8 -8
- {pymud-0.19.2.post1.dist-info → pymud-0.19.2.post2.dist-info}/WHEEL +0 -0
- {pymud-0.19.2.post1.dist-info → pymud-0.19.2.post2.dist-info}/entry_points.txt +0 -0
- {pymud-0.19.2.post1.dist-info → pymud-0.19.2.post2.dist-info}/top_level.txt +0 -0
pymud/objects.py
CHANGED
@@ -586,17 +586,19 @@ class Command(MatchObject):
|
|
586
586
|
__abbr__ = "cmd"
|
587
587
|
def __init__(self, session, patterns, *args, **kwargs):
|
588
588
|
super().__init__(session, patterns, sync = False, *args, **kwargs)
|
589
|
-
self._tasks =
|
589
|
+
self._tasks = set()
|
590
590
|
|
591
591
|
def create_task(self, coro, *args, name = None):
|
592
592
|
task = self.session.create_task(coro, *args, name)
|
593
|
-
self._tasks.
|
593
|
+
task.add_done_callback(self._tasks.discard)
|
594
|
+
self._tasks.add(task)
|
594
595
|
return task
|
595
596
|
|
596
597
|
def remove_task(self, task: asyncio.Task, msg = None):
|
597
598
|
result = self.session.remove_task(task, msg)
|
598
|
-
|
599
|
-
|
599
|
+
self._tasks.discard(task)
|
600
|
+
# if task in self._tasks:
|
601
|
+
# self._tasks.remove(task)
|
600
602
|
return result
|
601
603
|
|
602
604
|
def reset(self):
|
pymud/session.py
CHANGED
@@ -166,7 +166,8 @@ class Session:
|
|
166
166
|
|
167
167
|
self._variables = DotDict()
|
168
168
|
|
169
|
-
self._tasks = []
|
169
|
+
#self._tasks = []
|
170
|
+
self._tasks = set()
|
170
171
|
|
171
172
|
self._command_history = []
|
172
173
|
|
@@ -450,18 +451,21 @@ class Session:
|
|
450
451
|
else:
|
451
452
|
task = self.loop.create_task(coro, name = name)
|
452
453
|
#task = asyncio.create_task(coro, name = name)
|
453
|
-
self._tasks.
|
454
|
+
task.add_done_callback(self._tasks.discard)
|
455
|
+
self._tasks.add(task)
|
456
|
+
#self._tasks.append(task)
|
454
457
|
return task
|
455
458
|
|
456
459
|
def remove_task(self, task: asyncio.Task, msg = None):
|
457
460
|
result = task.cancel()
|
458
|
-
|
459
|
-
|
461
|
+
self._tasks.discard(task)
|
462
|
+
# if task in self._tasks:
|
463
|
+
# self._tasks.remove(task)
|
460
464
|
return result
|
461
465
|
|
462
466
|
def clean_finished_tasks(self):
|
463
467
|
"清理已经完成的任务"
|
464
|
-
self._tasks = [t for t in self._tasks if not t.done()]
|
468
|
+
self._tasks = set([t for t in self._tasks if not t.done()])
|
465
469
|
|
466
470
|
# for task in self._tasks:
|
467
471
|
# if isinstance(task, asyncio.Task) and task.done():
|
@@ -640,7 +644,7 @@ class Session:
|
|
640
644
|
if notAlias:
|
641
645
|
self.writeline(cmdtext)
|
642
646
|
|
643
|
-
self.clean_finished_tasks()
|
647
|
+
# self.clean_finished_tasks()
|
644
648
|
|
645
649
|
async def exec_text_async(self, cmdtext: str):
|
646
650
|
isNotCmd = True
|