Skip to content

Add per thread/test setup hook? #189

Description

@seberg

I was trying to use pytest-run-parallel for lowlevel CUDA code. In that context it happens that we need a per-thread setup (i.e. cuInit)

Doing that for almost every test as a decorator isn't nice, so one would use a fixture in pytest, but in pytest-run-parallel this isn't feasible.

I guess in an ideal world, one would have a setup_thread() hook that:

  • Runs before the barrier.
  • Knows the fixtures and *args, *kwargs probably. And can even replace them (i.e. per-thread context).

Or even something like a fixture(scope="thread") but I don't think that is possible :).

Right now, I can solve this (minus the barrier) by creating my own little pytest plugin that does the per-thread init, this isn't terribly difficult. It just leaves the nagging feeling that maybe it would be better to have a hook here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions