uqfoundation / dill

serialize all of Python

Home Page:http://dill.rtfd.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Dill 0.3.6 fails running Dash background callback on Windows

Shihan150 opened this issue · comments

I'm writing a Python project that needs Dash background callback. The code works well on the Mac system but fails on Windows. It is similar to the problem reported here and it should be related to Dill package. Now let me take the multi_page_cache_background_callback demo as an example.

  1. If I use the Dill 0.3.6.0 version, TypeError: can't pickle _abc_data objects will occur.
  2. I tried to downgrade Dill to 0.3.5.1, the demo example works.
  3. However, I found that Dill 0.3.5.1 cannot deal with the global parameters, which is used in my project.

The most interesting thing is both my project code and the demo code run successfully on the Mac system (with Dill 0.3.6.0), but fail on Windows. I tried to compare the version of packages used in two environments and made sure they are the same. So I guess it is probably not due to the inconsistency caused by different version packages?

Hard to tell what's going on here as I don't have any example code to look at and/or try, and also no tracebacks. It feels like to me a duplicate issue, given the fairly general description. Pickling can be different across OS and versions of python and dill. Note that your link above doesn't go to an example.

Here's an example page that will cause the error:
If you remove the boto3 line it works.
dill_test.tar.gz

import time

import boto3
import dash
from dash import html, callback, Output, Input

s3cli = boto3.client('s3')


layout = html.Div([
    html.Button("Click Me!", id='action1'),
    html.Div(id='action1_out'),
])

dash.register_page("dill_test", path="/", layout=layout)

@callback(
    Output('action1_out', 'children'),
    Input('action1',  'n_clicks'),
    background=True,
    running=[
        (Output("action1", 'disabled'), True, False),
    ]
)
def button_handler(n):
    time.sleep(1)
    return f"Clicked {n} times"

My project requirements:

[tool.poetry.dependencies]
python = ">=3.10.0,<3.11"
boto3 = "^1.28.40"
dash-bootstrap-components = "^1.4.2"
dash = {extras = ["compress","diskcache"], version = "^2.13.0"}
flask-compress = "^1.13"
diskcache = "^5.6.3"
botocore = "^1.31.84"

Without getting into it just yet, it would seem like to me that s3cli = boto3.client('s3') creates a unpicklable object. What's the error you see? What OS are you using (Windows? and if so, is it only on that OS you are experiencing the issue)? What version of dill are you using? Does your experience agree with the OP's enumerated comments? Does this only happen on the python you noted in your requirements? If this is different than what the OP experienced, it should be in its own issue.