File: crash_example.py

package info (click to toggle)
pytango 10.0.2-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 10,216 kB
  • sloc: python: 28,206; cpp: 16,380; sql: 255; sh: 82; makefile: 43
file content (25 lines) | stat: -rw-r--r-- 760 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# SPDX-FileCopyrightText: All Contributors to the PyTango project
# SPDX-License-Identifier: LGPL-3.0-or-later
"""
This crashes under PyTango 9.3.3 and cppTango 9.3.4.  Possibly other versions too.
"""

from tango.test_context import DeviceTestContext
import tango
import time


class Device1(tango.server.Device):
    pass


with DeviceTestContext(Device1, process=True) as proxy:
    cb = tango.utils.EventCallback()
    eid = proxy.subscribe_event("state", tango.EventType.ATTR_CONF_EVENT, cb)
    sleep = 12  # sleep >~11 ==> SIGSEGV ; sleep<10 ==> exit OK
    for i in range(sleep):
        time.sleep(1)
        print(i + 1, end=", ")
    print("\nbefore unsubscribe")
    proxy.unsubscribe_event(eid)  # <-- SEGFAULT here
    print("after unsubscribe")