Python Forum
Missing 1 required position argument: 'failure' while starting thread.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Missing 1 required position argument: 'failure' while starting thread.
#1
Error:
TypeError: scrape_child_link() missing 1 required positional argument: 'failure'
When I get to the following part in my code the above happens.
class A(object):
    def start(self):
        ....
        kill = threading.Event()
        # starting here
        child_link_thread = threading.Thread(target=ThreadExecutioner.execute_child,args=(self.scrape_child_link, child_link_queue, self.site, code_io_handle, text_io_handle, kill)).start()
        ....
    @staticmethod
    def scrape_child_link(self, link: str, used_children: Queue, site: StackOverflow, code_io_handle, text_io_handle,failure: threading.Event):
        ....
    

class ThreadExecutioner():
    @staticmethod
    def execute_child(target: callable(object), tasks: Queue, site: source, code_io_handle, text_io_handle,kill: threading.Event):
        parent_threader = threading.Thread(target=target,args=(task, hit_queue, site, code_io_handle,text_io_handle, kill),daemon=True)
        parent_threader.start() #Exception thrown here
    
Ive stepped through this and all of the variables are set by the time the second thread is dispatched. But for some reason the thread does not recognize the kill variable
Reply
#2
Have you tried passing self as the first argument? I know that seems strange since it's automatic, but passing a method into a thread could disassociated the method and self. If that fixes it, the problem would be that it's applying the arguments to each parameter and coming up one short.

Edit: On a related note, you should probably refactor so you aren't passing a method. I imagine that's a thread safety issue.
Reply
#3
(Jun-17-2020, 10:33 PM)stullis Wrote: Have you tried passing self as the first argument? I know that seems strange since it's automatic, but passing a method into a thread could disassociated the method and self. If that fixes it, the problem would be that it's applying the arguments to each parameter and coming up one short.

Edit: On a related note, you should probably refactor so you aren't passing a method. I imagine that's a thread safety issue.

That did not solve the issue. I'm trying to migrate some code someone else wrote to a new project, so refactoring is not desired.
Reply
#4
Okay, I looked at it again. There's a problem with the number of parameters and arguments.

The args passed to ThreadExecutioner.execute_child() contains six values. The first value is scrape_child_link() which has six parameters as well; this leaves only five arguments to be passed into scrape_child_link(). Based on the variable names provided, it seems the link parameter of scrape_child_link() has no argument when ThreadExecutioner.execute_child() calls scrape_child_link().

So, ThreadExecutioner.execute_child() requires an additional argument to properly run scrape_child_link().
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Failure to run source command middlestudent 2 656 Sep-22-2023, 01:21 PM
Last Post: buran
  Dickey Fuller failure Led_Zeppelin 4 2,531 Sep-15-2022, 09:07 PM
Last Post: Led_Zeppelin
  TypeError: missing a required argument: 'y' gible 0 2,844 Dec-15-2021, 02:21 AM
Last Post: gible
  Assert failure jtcostel 1 1,614 Sep-03-2021, 05:28 PM
Last Post: buran
  TypeError: missing 3 required positional arguments: wardancer84 9 10,663 Aug-19-2021, 04:27 PM
Last Post: deanhystad
  TypeError: run_oracle_job() missing 1 required positional argument: 'connection_strin python_student 1 1,937 Aug-06-2021, 08:05 PM
Last Post: SheeppOSU
  TypeError: max_value() missing 2 required positional arguments: 'alpha' and 'beta' Anldra12 2 4,167 May-15-2021, 04:15 PM
Last Post: Anldra12
  TypeError: sum() missing 1 required positional argument: 'num2' Insen 3 5,385 Jan-06-2021, 04:25 PM
Last Post: Insen
  TypeError: forward() missing 1 required positional argument: 'x' sveto4ka 4 12,172 Jun-17-2020, 07:25 PM
Last Post: sveto4ka
  missing 1 required positional argument: 'self' yasser 7 11,295 Jun-07-2020, 06:48 AM
Last Post: ndc85430

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020