<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body text="#000000" bgcolor="#cccccc">
<tt>Zdravim vsechny,<br>
<br>
mam maly problem s ukladanim scapy paketu do fronty (multiprocess).
Priklad:<br>
<br>
from multiprocessing import Process<br>
from multiprocessing.managers import BaseManager<br>
from scapy.all import sniff<br>
<br>
class Worker(Process):<br>
'''<br>
Class for sniffing packets, runnig as root<br>
'''<br>
def __init__(self):<br>
super(Worker, self).__init__()<br>
self.iface = ''<br>
self.expr = ''<br>
# key for queue daemon, remotely on localhost:5000<br>
self._keyQ = '10b222970537b97919db36ec757370d2'<br>
class QueueManager(BaseManager): pass<br>
QueueManager.register('get_dataQueue')<br>
self._m = QueueManager(address=('127.0.0.1', 5000),
authkey=self._keyQ)<br>
self._m.connect()<br>
self.dataQueue = self._m.get_dataQueue()<br>
def go(self, iface, expr):<br>
print "Starting sniffer"<br>
self.iface = iface<br>
self.expr = expr<br>
super(Worker, self).start()<br>
def run(self):<br>
print "sniffing ..."<br>
print self.iface<br>
print self.expr<br>
print self.dataQueue<br>
packets = sniff(filter=self.expr, count=10, timeout=10,
iface=self.iface)<br>
print packets<br>
self.dataQueue.put(packets)<br>
print "... done"<br>
<br>
<br>
But always getting:<br>
Traceback (most recent call last):<br>
File "/usr/lib/python2.6/multiprocessing/process.py", line 232, in
_bootstrap<br>
self.run()<br>
File "/home/tom/web2py/applications/NetSim/DAEMON/Worker.py", line
32, in run<br>
self.dataQueue.put(packets)<br>
File "<string>", line 2, in put<br>
File "/usr/lib/python2.6/multiprocessing/managers.py", line 725, in
_callmethod<br>
conn.send((self._id, methodname, args, kwds))<br>
PicklingError: Can't pickle <type 'function'>: attribute lookup
__builtin__.function failed<br>
<br>
<br>
PAkety nejsou snad serializovatelne? Nesetkal se s touto chybou uz
nekdo drive?<br>
<br>
Diky za rady</tt>
<pre class="moz-signature" cols="72">--
Tomas Pelka</pre>
</body>
</html>