Giter Site home page Giter Site logo

Comments (4)

willkg avatar willkg commented on September 3, 2024

What does the traceback look like?

from elasticutils.

toopy avatar toopy commented on September 3, 2024

It can be obtained from this kind of code:

class MyMappingType(MappingType, Indexable):
    def reindex_all(cls):
        tasks.index_objects.delay(cls, cls.get_model().objects.values_list('id', flat=True), id_field=cls.id_field)

Here is the full traceback:

(myapp)florent@florent:~/Work/myapp/myapp$ myapp reindex_all
Traceback (most recent call last):
  File "/home/florent/.virtualenvs/myapp/bin/myapp", line 9, in <module>
    load_entry_point('myapp==0.1dev', 'console_scripts', 'myapp')()
  File "/home/florent/Work/myapp/myapp/myapp/manage.py", line 10, in main
    execute_from_command_line(sys.argv)
  File "/home/florent/.virtualenvs/myapp/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
    utility.execute()
  File "/home/florent/.virtualenvs/myapp/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/florent/.virtualenvs/myapp/local/lib/python2.7/site-packages/django/core/management/base.py", line 242, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/home/florent/.virtualenvs/myapp/local/lib/python2.7/site-packages/django/core/management/base.py", line 285, in execute
    output = self.handle(*args, **options)
  File "/home/florent/Work/myapp/myapp/myapp/management/commands/reindex_all.py", line 21, in handle
    m_type.run_index_all()
  File "/home/florent/Work/myapp/django-esutils/django_esutils/mappings.py", line 194, in run_index_all
    flat=True))
  File "/home/florent/Work/myapp/django-esutils/django_esutils/mappings.py", line 189, in run_index
    tasks.index_objects.delay(cls, ids, id_field=cls.id_field)
  File "/home/florent/.virtualenvs/myapp/local/lib/python2.7/site-packages/celery/app/task.py", line 453, in delay
    return self.apply_async(args, kwargs)
  File "/home/florent/.virtualenvs/myapp/local/lib/python2.7/site-packages/celery/app/task.py", line 547, in apply_async
    link=link, link_error=link_error, **options)
  File "/home/florent/.virtualenvs/myapp/local/lib/python2.7/site-packages/celery/app/task.py", line 739, in apply
    request=request, propagate=throw)
  File "/home/florent/.virtualenvs/myapp/local/lib/python2.7/site-packages/celery/app/trace.py", line 354, in eager_trace_task
    uuid, args, kwargs, request)
  File "/home/florent/.virtualenvs/myapp/local/lib/python2.7/site-packages/celery/app/trace.py", line 253, in trace_task
    I, R, state, retval = on_error(task_request, exc, uuid)
  File "/home/florent/.virtualenvs/myapp/local/lib/python2.7/site-packages/celery/app/trace.py", line 240, in trace_task
    R = retval = fun(*args, **kwargs)
  File "/home/florent/Work/myapp/elasticutils/elasticutils/contrib/django/tasks.py", line 48, in index_objects
    ids[0], ids[-1], len(ids)))
  File "/home/florent/.virtualenvs/myapp/local/lib/python2.7/site-packages/django/db/models/query.py", line 112, in __getitem__
    "Negative indexing is not supported."
AssertionError: Negative indexing is not supported.

from elasticutils.

willkg avatar willkg commented on September 3, 2024

It looks like you're passing an iterator as a task argument. I really wouldn't do this. I'd pass either a list or a tuple and not an iterator. Easy way to do this is to wrap your queryset in a list() call.

from elasticutils.

toopy avatar toopy commented on September 3, 2024

According that, in real life, the index task is running asynchronously, it's clearly dangerous. I close.

from elasticutils.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.