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
  Weird failure in Selenium glestwid 1 443 Oct-03-2025, 08:57 AM
Last Post: Larz60+
  SSL Handshake Failure with Python 3.11 and 3.12 Samanth_m 0 3,280 Nov-15-2024, 03:35 PM
Last Post: Samanth_m
  Failure to run source command middlestudent 2 1,915 Sep-22-2023, 01:21 PM
Last Post: buran
  Dickey Fuller failure Led_Zeppelin 4 5,184 Sep-15-2022, 09:07 PM
Last Post: Led_Zeppelin
  TypeError: missing a required argument: 'y' gible 0 4,575 Dec-15-2021, 02:21 AM
Last Post: gible
  Assert failure jtcostel 1 2,699 Sep-03-2021, 05:28 PM
Last Post: buran
  TypeError: missing 3 required positional arguments: wardancer84 9 17,527 Aug-19-2021, 04:27 PM
Last Post: deanhystad
  TypeError: run_oracle_job() missing 1 required positional argument: 'connection_strin python_student 1 3,135 Aug-06-2021, 08:05 PM
Last Post: SheeppOSU
  TypeError: max_value() missing 2 required positional arguments: 'alpha' and 'beta' Anldra12 2 5,541 May-15-2021, 04:15 PM
Last Post: Anldra12
  TypeError: sum() missing 1 required positional argument: 'num2' Insen 3 8,038 Jan-06-2021, 04:25 PM
Last Post: Insen

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020
This forum uses Lukasz Tkacz MyBB addons.
Forum use Krzysztof "Supryk" Supryczynski addons.