1

当我尝试执行以下 python 脚本时:

/usr/bin/python /var/www/html/iPhone/inarrivo/python/addMurmurChannel.py 14 我收到错误:在全局销毁期间通信器未销毁。

什么是通讯器,我如何销毁它?

#!/usr/bin/python
import Ice
import inspect
import sys
#Ice.loadSlice("/usr/local/murmur/ice/Murmur.ice")
Ice.loadSlice( '', ['-I' + Ice.getSliceDir(), "/usr/local/murmur/ice/Murmur.ice"])
import Murmur
newChannelName=sys.argv[1]
# Init ice
comm = Ice.initialize()
# Let Ice know where to go to connect to mumble
# Let Ice know where to go to connect to mumble
proxy = comm.stringToProxy("Meta -e 1.0:tcp -p 6502")
# Create a dynamic object that allows us to get a programmable interface for Mumble
meta = Murmur.MetaPrx.checkedCast(proxy)
# Get the server instance from the set of servers.
server = meta.getServer(1)
found=False
channels = server.getChannels()
for value in channels.itervalues():
    idChannel=value.id
    if value.name == newChannelName:
            found=True
            break
if found==False:
    server.addChannel(newChannelName, 0)
4

1 回答 1

0

打电话时

ic = Ice.initialize()

创建了一个通信器。你可以像这样销毁它:

if ic:
    # Clean up
    try:
        ic.destroy()
    except:
        traceback.print_exc()
        status = 1

参考:https ://doc.zeroc.com/display/Ice36/Writing+an+Ice+Application+with+Python#WritinganIceApplicationwithPython-WritingaClientinPython

于 2017-01-20T08:12:27.747 回答