2

尝试运行 hello world 示例以将某些内容放在队列中,创建一个队列......每当我调用 azure 时,我都会收到错误消息。

这是代码:

from azure.servicebus import *

bus_service = ServiceBusService(service_namespace='testtest', account_key='my_access_token', issuer='my_issuer')
bus_service.create_topic('mytopic')

这是我回来的错误:

$ /c/Python27/python pythontest.py
Traceback (most recent call last):
  File "pythontest.py", line 4, in <module>
    bus_service.create_topic('mytopic')
  File "c:\Python27\lib\site-packages\azure\servicebus\servicebusservice.py", line 1
42, in create_topic
    request.headers = _update_service_bus_header(request, self.account_key, self.iss
uer)
  File "c:\Python27\lib\site-packages\azure\servicebus\__init__.py", line 185, in _u
pdate_service_bus_header
    request.headers.append(('Authorization', _sign_service_bus_request(request, acco
unt_key, issuer)))
  File "c:\Python27\lib\site-packages\azure\servicebus\__init__.py", line 192, in _s
ign_service_bus_request
    return 'WRAP access_token="' + _get_token(request, account_key, issuer) + '"'
  File "c:\Python27\lib\site-packages\azure\servicebus\__init__.py", line 233, in _g
et_token
    connection.send(request_body)
  File "c:\Python27\lib\site-packages\azure\http\winhttp.py", line 313, in send
    self._httprequest.send(request_body)
  File "c:\Python27\lib\site-packages\azure\http\winhttp.py", line 198, in send
    ctypes.memmove(safearray.pvdata, request, len(request))
WindowsError: exception: access violation writing 0x0000000000000000

无论我将某些内容放在队列上还是创建队列、创建主题、向主题发送消息等,它总是给我同样的错误。

有任何想法吗?

4

2 回答 2

0

这是您使用的确切代码吗?至少account_key不对,应该是base64格式

bus_service = ServiceBusService(service_namespace='testtest', account_key='my_access_token', issuer='my_issuer') 
于 2012-06-12T19:21:20.980 回答
0

当从 64 位 Python 使用时,这是 azure 库的问题。

使其工作的更改很小,因此我在此处为您列出了它们。该修复程序也将很快推送到 github + pypi。

对azure/http/winhttp.py进行以下更改:

c_size_t添加到导入语句

from ctypes import c_void_p, c_long, c_ulong, c_longlong, c_ulonglong, c_short, c_ushort, c_wchar_p, c_byte, c_size_t

CoInitialize(0)替换为

CoInitialize(None)

用这个替换Com 相关的 APIs部分

_ole32 = oledll.ole32
_oleaut32 = WinDLL('oleaut32')
_CLSIDFromString = _ole32.CLSIDFromString
_CoInitialize = _ole32.CoInitialize
_CoInitialize.argtypes = [c_void_p]

_CoCreateInstance = _ole32.CoCreateInstance

_SysAllocString = _oleaut32.SysAllocString
_SysAllocString.restype = c_void_p
_SysAllocString.argtypes = [c_wchar_p]

_SysFreeString = _oleaut32.SysFreeString
_SysFreeString.argtypes = [c_void_p]

_SafeArrayDestroy = _oleaut32.SafeArrayDestroy
_SafeArrayDestroy.argtypes = [c_void_p]

_CoTaskMemAlloc = _ole32.CoTaskMemAlloc
_CoTaskMemAlloc.restype = c_void_p
_CoTaskMemAlloc.argtypes = [c_size_t]
于 2012-06-14T22:19:07.550 回答