我现在的目标是创建团队讲3管理员服务(通过渠道切换用户): 所以我创建了TS3 SDK lib的包装器(用Cython for Python包装):https://mega.nz/#!pQdFjIwD!1vg8DPsFtYR4icVqWXzvpdbAQ47-n-aPz2niRkTU4fY(主模块:http://pastebin.com/PywhH4bf) 在这个包装器中,我在模块中使用了测试连接。要测试此模块,只需导入它。
我在python控制台中收到消息(调用ts3client_startConnection
后):Process finished with exit code -1073741819 (0xC0000005)
(访问冲突)
另外我看到TS3回调是从非主线程调用的。
使用此日志:
2016-08-16 10:14:20.862577|INFO | | |TeamSpeak 3 Client 3.0.3 (2015-03-30 11:30:36) SDK
2016-08-16 10:14:20.863574|INFO | | |SystemInformation: Windows 9 8664 {6} {3} {9600} (9600) x64 (AMD or Intel) Binary: 32bit
2016-08-16 10:14:20.863574|INFO | | |Using hardware aes
2016-08-16 10:14:20.876587|DEBUG |Direct Sound | |setting timer resolution to 1ms
2016-08-16 10:14:20.892602|ERROR |SoundBckndIntf| |Could not load "ts3soundbackend_isSupported" from backend dynamic library
spawn connection handler
mode
Default capture mode: b'Windows Audio Session'
('Default capture device: %s %s\n', b'\xd0\x9c\xd0\xb8\xd0\xba\xd1\x80\xd0\xbe\xd1\x84\xd0\xbe\xd0\xbd (\xd0\xa3\xd1\x81\xd1\x82\xd1\x80\xd0\xbe\xd0\xb9\xd1\x81\xd1\x82\xd0\xb2\xd0\xbe \xd1\x81 \xd0\xbf\xd0\xbe\xd0\xb4\xd0\xb4\xd0\xb5\xd1\x80\xd0\xb6\xd0\xba\xd0\xbe\xd0\xb9 High Definition Audio)', b'{0.0.1.00000000}.{c28d826f-9cd5-414b-a018-bbfc0cbc1298}')
2016-08-16 10:14:20.905616|DEBUG |Windows Audio Session| |WAS::openDevice-enter
2016-08-16 10:14:20.912622|DEBUG |Windows Audio Session| |WAS Buffer size: 896
2016-08-16 10:14:20.912622|DEBUG |Windows Audio Session| |WAS::openDevice-leave
2016-08-16 10:14:20.912622|INFO |PreProSpeex |1 |Speex version: speex-1.2beta3
2016-08-16 10:14:20.912622|DEBUG |Windows Audio Session| |WAS::startDevice-enter
2016-08-16 10:14:20.913622|DEBUG |Windows Audio Session| |WAS::startDevice-leave
Default playback mode: b'Windows Audio Session'
('Default playback device: %s %s\n', b'\xd0\x94\xd0\xb8\xd0\xbd\xd0\xb0\xd0\xbc\xd0\xb8\xd0\xba\xd0\xb8 (\xd0\xa3\xd1\x81\xd1\x82\xd1\x80\xd0\xbe\xd0\xb9\xd1\x81\xd1\x82\xd0\xb2\xd0\xbe \xd1\x81 \xd0\xbf\xd0\xbe\xd0\xb4\xd0\xb4\xd0\xb5\xd1\x80\xd0\xb6\xd0\xba\xd0\xbe\xd0\xb9 High Definition Audio)', b'{0.0.0.00000000}.{cb324415-bf79-473b-9a59-69a1ca4bfe56}')
2016-08-16 10:14:20.913622|DEBUG |Windows Audio Session| |WAS::openDevice-enter
2016-08-16 10:14:20.918627|DEBUG |Windows Audio Session| |WAS Buffer size: 896
2016-08-16 10:14:20.918627|DEBUG |Windows Audio Session| |WAS::openDevice-leave
2016-08-16 10:14:20.918627|DEBUG |Windows Audio Session| |WAS::startDevice-enter
2016-08-16 10:14:20.918627|DEBUG |Windows Audio Session| |WAS::startDevice-leave
creating identity
Using identity: b'295V/MObSjZ2wIe+dMWhUoLET/UpS6ENHlhWSVdYYSZ5UnQTU3dneUFQLAF/FDVRBXkaFVFeAH10V1cDQn0Gd3BVYgFgXwV4IgxjOVB2DCwtET9TfgcaA31GE1MBZFxLBXtgDHd9WHFka0NJUUQweGprQnp2cjNrSkxBMXJaazRWeDJMTkRUOUlXcVVyZ0p0WnpDU0lDOVlRPT0='
Client lib initialized and running
Connect status changed: 1 1 0
2016-08-16 10:14:20.926635|DEVELOP |PktHandler | |Puzzle solve time: 7
Connect status changed: 1 2 0
Connect status changed: 1 3 0
Connect status changed: 1 4 0
此外,我没有可重复的随机错误:
Fatal Python error: GC object already tracked
和
Fatal Python error: PyThreadState_Get: no current thread
答案 0 :(得分:0)
由于缺乏可验证的例子,这有点猜测。
如果从C库(ts3client_ *)创建的线程调用这些处理函数,则在调用python函数时未正确获取GIL。
添加with gil
之类的
cdef void onConnectStatusChangeEvent(uint64 serverConnectionHandlerID,
int newStatus,
unsigned int errorNumber) with gil:
可能会有所帮助。
__main__()
末尾也没有代码,主线程至少闲置可能会更好。
if (error != ERROR_ok):
print("Error connecting to server: %d\n"% error)
print("Client lib initialized and running\n")
在打印电话之后可以添加以下行以进行快速测试
import time
while True:
time.sleep(1.0)