On 09.01.2018 02:28, Percy wrote:
> Hello, Tiago!
> 
>  A small example to reproduce the problem please find as the following.
> 
> import multiprocess as mp
> import graph_tool.all as gt
> import numpy as np
> 
> g = gt.price_network(20, m = 2, directed = False)
> valid_paths = g.new_vertex_property("object")
> g.vertex_properties["valid_paths"] = valid_paths
> 
> Cloudlet = []
> Gateway = []
> for v in g.vertices():
>     if np.random.rand() > 0.5:
>         Cloudlet.append(v)
>     else:
>         Gateway.append(v)
> 
> pool = mp.Pool(processes=4)
> for v in Gateway:
>     valid_paths[v] = pool.map(lambda x: gt.all_shortest_paths(g = g, source
> = g.vertex_index[v], target = x),[g.vertex_index[c] for c in Cloudlet])
> 
> The version of my graph-tool is 2.25. Now, the python compiler says 
> 
> MaybeEncodingError: Error sending result:
> '[<graph_tool.libgraph_tool_core.CoroGenerator object at 0x7f344b5f4f80>]'.
> Reason: 'RuntimeError('Pickling of
> "graph_tool.libgraph_tool_core.CoroGenerator" instances is not enabled
> (http://www.boost.org/libs/python/doc/v2/pickle.html)',)'
> 
> I know vertex objects cannot be picked. However, I think I have converted
> vertex objects into a int list before sending them to map function, i.e.,
> "[g.vertex_index[c] for c in Cloudlet]". In particular, we can print
> [g.vertex_index[c] for c in Cloudlet], and terminal shows something like
> [1,2,3,4,5].
> 
> Is there any thing I misunderstand ?

As the error says, the iterator objects returned by all_shortest_paths()
cannot be pickled. The values returned by the function fed to pool.map()
must be pickable. Hence you need to convert the iterator to lists or
something else before returning.


-- 
Tiago de Paula Peixoto <[email protected]>

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
graph-tool mailing list
[email protected]
https://lists.skewed.de/mailman/listinfo/graph-tool

Reply via email to