通过dbus传递大型数据结构 [英] Passing a large data structure over dbus
问题描述
我正在使用dbus交流两个程序。一个创建一个大图像,然后将其发送给其他程序进行进一步处理。我将图像作为ByteArray传递。
I'm using dbus to communicate two programs. One creates a large image and it later sends it other program for further processing. I'm passing the image as ByteArray.
对于2000x2000的图像,我的程序可以工作,但对于4000x4000的程序,其苛刻之处是:
With 2000x2000 images my program works, but with 4000x4000 it crasses with:
process 2283: arguments to dbus_message_iter_append_fixed_array() were
incorrect,assertion "n_elements <= DBUS_MAXIMUM_ARRAY_LENGTH / _dbus_type_get_alignment
(element_type)" failed in file dbus-message.c line 2628.
我知道这意味着我传递的数组大于允许的范围。还有其他在dbus中传递大数据结构的方法吗?
I understand that this means that I'm passing an array larger than allowed. Is there other way of passing large data strucutures in dbus?
这是我正在使用的代码的摘录:
This is an excerpt of the code I'm using:
handle = StringIO()
# hdulist contains the large data structure
hdulist.writeto(handle)
hdub = dbus.ByteArray(handle.getvalue())
# this sends the image via dbus
self.dbi.store_image(hdub)
发送图像
在另一端,我有类似
In the other end I have something like
def store_image(self, bindata):
# Convert binary data back to HDUList
handle = StringIO.StringIO(bindata)
hdulist = pyfits.open(handle)
推荐答案
我认为Dbus并不是发送大量数据的最佳方法。
I don't think Dbus is really the best way to send large amounts of data.
如何将数据结构写到/ tmp中的文件中,而只是通过dbus在程序之间传递文件名?
How about writing the data structure out to a file in /tmp, and just passing the filename between the programs via dbus instead?
这篇关于通过dbus传递大型数据结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!