(self)
| 60 | self.update_name() |
| 61 | |
| 62 | def update_name(self): |
| 63 | tasklet = self.tasklet_weakref() |
| 64 | if tasklet: |
| 65 | if tasklet.blocked: |
| 66 | state = "blocked" |
| 67 | elif tasklet.paused: |
| 68 | state = "paused" |
| 69 | elif tasklet.scheduled: |
| 70 | state = "scheduled" |
| 71 | else: |
| 72 | state = "<UNEXPECTED>" |
| 73 | |
| 74 | try: |
| 75 | name = tasklet.name |
| 76 | except AttributeError: |
| 77 | if tasklet.is_main: |
| 78 | name = "MainTasklet" |
| 79 | else: |
| 80 | name = "Tasklet-%s" % (self._tasklet_id,) |
| 81 | |
| 82 | thread_id = tasklet.thread_id |
| 83 | if thread_id != -1: |
| 84 | for thread in threading.enumerate(): |
| 85 | if thread.ident == thread_id: |
| 86 | if thread.name: |
| 87 | thread_name = "of %s" % (thread.name,) |
| 88 | else: |
| 89 | thread_name = "of Thread-%s" % (thread.name or str(thread_id),) |
| 90 | break |
| 91 | else: |
| 92 | # should not happen. |
| 93 | thread_name = "of Thread-%s" % (str(thread_id),) |
| 94 | thread = None |
| 95 | else: |
| 96 | # tasklet is no longer bound to a thread, because its thread ended |
| 97 | thread_name = "without thread" |
| 98 | |
| 99 | tid = id(tasklet) |
| 100 | tasklet = None |
| 101 | else: |
| 102 | state = "dead" |
| 103 | name = "Tasklet-%s" % (self._tasklet_id,) |
| 104 | thread_name = "" |
| 105 | tid = "-" |
| 106 | self.tasklet_name = "%s %s %s (%s)" % (state, name, thread_name, tid) |
| 107 | |
| 108 | if not hasattr(stackless.tasklet, "trace_function"): |
| 109 | # bug https://bitbucket.org/stackless-dev/stackless/issue/42 |
no outgoing calls
no test coverage detected