You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Create a view from that base_table then create a derived_table from that view, with the derived_table updating with deltas from the view
then you host BOTH tables with the manager
Any code containing this will segfault very quickly
# you have a base_table + managerMANAGER=perspective.PerspectiveManager()
BASE_TABLE=perspective.Table(columns, index="index")
# create a view from that base_table then create a derived_table from that viewVIEW=BASE_TABLE.view()
DERIVED_TABLE=perspective.Table(VIEW.to_arrow(), index=BASE_TABLE.get_index())
VIEW.on_update(updater_func, "row")
# then you host BOTH tablesMANAGER.host(BASE_TABLE, "base")
MANAGER.host(DERIVED_TABLE, "DERIVED")
where updater_func fed into VIEW.on_update can either be
importasyncioimportsocketimportthreadingimporttornadoimporttornado.webimporttornado.ioloopimporttornado.genimportperspectiveclassMainHandler(tornado.web.RequestHandler):
definitialize(self, domain: str, port: int, table_name: str):
self.port=portself.domain=domainself.table_name=table_namedefget(self):
self.write("")
defmake_app(
MANAGER: perspective.PerspectiveManager, domain: str, port: int, table_name: str,
):
handlers= [
(
r"/websocket",
perspective.PerspectiveTornadoHandler,
{"manager": MANAGER, "check_origin": True},
),
(
r"/",
MainHandler,
{"domain": domain, "port": port, "table_name": table_name},
),
]
app=tornado.web.Application(handlers)
returnappdefperspective_thread(MANAGER: perspective.PerspectiveManager):
loop=tornado.ioloop.IOLoop()
MANAGER.set_loop_callback(loop.add_callback)
loop.start()
defasync_updater(table: perspective.Table, manager: perspective.PerspectiveManager):
defupdate_function(port: int, delta):
manager.call_loop(table.update, delta)
returnupdate_functiondefsync_updater(table: perspective.Table, manager: perspective.PerspectiveManager):
defupdate_function(port: int, delta):
table.update(delta)
returnupdate_functionasyncdefmain(async_mode: bool):
print("starting up.")
columns= {"index": int, "num1": int, "num2": int}
MANAGER=perspective.PerspectiveManager()
BASE_TABLE=perspective.Table(columns, index="index")
table_name="base_table"VIEW=BASE_TABLE.view()
DERIVED_TABLE=perspective.Table(VIEW.to_arrow(), index=BASE_TABLE.get_index())
MANAGER.host(BASE_TABLE, table_name)
MANAGER.host(DERIVED_TABLE, "DERIVED")
VIEW.on_update(async_updater(DERIVED_TABLE, MANAGER), "row")
# if you comment out *either* of the above 2 line, it works# you can even replace async_updater with sync_updater""" # below does not work either if you put it after the loop_callback is set MANAGER.call_loop( VIEW.on_update, async_updater(DERIVED_TABLE, MANAGER), "row", ) """ifasync_mode:
thread=threading.Thread(target=perspective_thread, args=(MANAGER,))
thread.daemon=Truethread.start()
whileMANAGER._loop_callbackisNone:
print("Pausing to let Perspective Manager thread set up.")
awaitasyncio.sleep(1)
else:
loop=asyncio.get_event_loop()
MANAGER.set_loop_callback(loop.call_soon)
domain=socket.gethostname()
port=8080app=make_app(MANAGER, domain, port, table_name)
app.listen(port)
print(f"url: {domain}:{port}")
i=0MANAGER.call_loop(BASE_TABLE.update, [{"index": i, "num1": i, "num2": 2*i}])
whileTrue:
awaitasyncio.sleep(0.001)
MANAGER.call_loop(BASE_TABLE.update, [{"index": i, "num1": i, "num2": 2*i}])
MANAGER.call_loop(
BASE_TABLE.update,
[{"index": p, "num1": p%3, "num2": 2*p+i} forpinrange(i)],
)
print(i)
i+=1if__name__=="__main__":
async_mode=Trueasyncio.run(main(async_mode), debug=True)
Expected Result:
No crashing
Actual Result:
Seg fault very soon after I start running
Environment:
linux
perspective 1.1.0
Additional Context:
I suspect it was the same issue I had back with this issue #1313, but I have narrowed down what specifically is wrong
This suggests that this is not a new bug
The text was updated successfully, but these errors were encountered:
This has been fixed in #1707 and will be in the v1.1.1 release. I find the PYTHONMALLOC=debug environment value to be quite helpful when isolating GIL issues, as opposed to relying on thread contention. I've added this mode to our test suite to help assert not just working tests, but strictly correct GIL usage for these, as well as a simplified version of your repro which fails consistently in this mode.
Bug Report
High Level Overview
Any code containing this will segfault very quickly
where
updater_func
fed intoVIEW.on_update
can either beBug Reproduction Code:
Minimal code reproduction on perspective 1.1.0
Expected Result:
No crashing
Actual Result:
Seg fault very soon after I start running
Environment:
linux
perspective 1.1.0
Additional Context:
I suspect it was the same issue I had back with this issue #1313, but I have narrowed down what specifically is wrong
This suggests that this is not a new bug
The text was updated successfully, but these errors were encountered: