Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Celery changing dict value types #8873

Open
18 tasks
kush1Bansal opened this issue Feb 26, 2024 · 1 comment
Open
18 tasks

Celery changing dict value types #8873

kush1Bansal opened this issue Feb 26, 2024 · 1 comment

Comments

@kush1Bansal
Copy link

I am using celery to offload some tasks from my python server
I have a function which is decorated with the @shared_task decorator.
I pass an argument to this function which is a dictionary like this:
my_dict = {1:2,3:4}
Both the key and the value are integer types.
When I pass this in the celery function and try to do this:
my_dict.get(1) # searching for the key 1 (integer) in my_dict, it returns nothing
and if I do
my_dict.get("1") it returns the value 2 (in type integer)

This means that somehow celery is changing the type of the keys in my dictionary.

Can you help me out in finding the RCA for this?

Checklist

  • I have verified that the issue exists against the main branch of Celery.
  • This has already been asked to the discussions forum first.
  • I have read the relevant section in the
    contribution guide
    on reporting bugs.
  • I have checked the issues list
    for similar or identical bug reports.
  • I have checked the pull requests list
    for existing proposed fixes.
  • I have checked the commit log
    to find out if the bug was already fixed in the main branch.
  • I have included all related issues and possible duplicate issues
    in this issue (If there are none, check this box anyway).

Mandatory Debugging Information

  • I have included the output of celery -A proj report in the issue.
    (if you are not able to do this, then at least specify the Celery
    version affected).
  • I have verified that the issue exists against the main branch of Celery.
  • I have included the contents of pip freeze in the issue.
  • I have included all the versions of all the external dependencies required
    to reproduce this bug.

Optional Debugging Information

  • I have tried reproducing the issue on more than one Python version
    and/or implementation.
  • I have tried reproducing the issue on more than one message broker and/or
    result backend.
  • I have tried reproducing the issue on more than one version of the message
    broker and/or result backend.
  • I have tried reproducing the issue on more than one operating system.
  • I have tried reproducing the issue on more than one workers pool.
  • I have tried reproducing the issue with autoscaling, retries,
    ETA/Countdown & rate limits disabled.
  • I have tried reproducing the issue after downgrading
    and/or upgrading Celery and its dependencies.

Related Issues and Possible Duplicates

Related Issues

  • None

Possible Duplicates

  • None

Environment & Settings

Celery version:

celery report Output:

Steps to Reproduce

Required Dependencies

  • Minimal Python Version: N/A or Unknown
  • Minimal Celery Version: N/A or Unknown
  • Minimal Kombu Version: N/A or Unknown
  • Minimal Broker Version: N/A or Unknown
  • Minimal Result Backend Version: N/A or Unknown
  • Minimal OS and/or Kernel Version: N/A or Unknown
  • Minimal Broker Client Version: N/A or Unknown
  • Minimal Result Backend Client Version: N/A or Unknown

Python Packages

pip freeze Output:

Other Dependencies

N/A

Minimally Reproducible Test Case

Expected Behavior

Actual Behavior

@vzografos
Copy link

vzografos commented Mar 30, 2024

yes I have seen this behaviour as well.

@app.task(name="some_task")
def some_task(input_data: dict) -> Dict[int, float]:
    resulting_value = random.uniform(0, 1)
    return {4: round(resulting_value, 4)}
    
    ...
    data_dict={None, None}
    res = some_task.delay(data_dict)
    result = AsyncResult(res.id)
    property_key, result_value = next(iter(result.result.items()))

....

('4', 0.1663)

From the celery worker side it looks fine:
e7f890fc282] succeeded in 5.0038198390002435s: {4: 0.1663}

Also if you do it via a Flask app it works properly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants