SILENT KILLERPanel

Current Path: > > opt > > hc_python > lib64 > > python3.12 > site-packages > greenlet


Operation   : Linux premium131.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64
Software     : Apache
Server IP    : 162.0.232.56 | Your IP: 216.73.216.111
Domains      : 1034 Domain(s)
Permission   : [ 0755 ]

Files and Folders in: //opt//hc_python/lib64//python3.12/site-packages/greenlet

NameTypeSizeLast ModifiedActions
__pycache__ Directory - -
platform Directory - -
tests Directory - -
CObjects.cpp File 3508 bytes May 23 2025 10:34:46.
PyGreenlet.cpp File 23441 bytes May 23 2025 10:34:46.
PyGreenlet.hpp File 1463 bytes May 23 2025 10:34:46.
PyGreenletUnswitchable.cpp File 4375 bytes May 23 2025 10:34:46.
PyModule.cpp File 8587 bytes May 23 2025 10:34:46.
TBrokenGreenlet.cpp File 1021 bytes May 23 2025 10:34:46.
TExceptionState.cpp File 1359 bytes May 23 2025 10:34:46.
TGreenlet.cpp File 25731 bytes May 23 2025 10:34:46.
TGreenlet.hpp File 28043 bytes May 23 2025 10:34:46.
TGreenletGlobals.cpp File 3264 bytes May 23 2025 10:34:46.
TMainGreenlet.cpp File 3276 bytes May 23 2025 10:34:46.
TPythonState.cpp File 15779 bytes May 23 2025 10:34:46.
TStackState.cpp File 7381 bytes May 23 2025 10:34:46.
TThreadState.hpp File 19131 bytes May 23 2025 10:34:46.
TThreadStateCreator.hpp File 2610 bytes May 23 2025 10:34:46.
TThreadStateDestroy.cpp File 8169 bytes May 23 2025 10:34:46.
TUserGreenlet.cpp File 23553 bytes May 23 2025 10:34:46.
__init__.py File 1723 bytes May 23 2025 10:34:46.
_greenlet.cpython-312-x86_64-linux-gnu.so File 1446128 bytes May 23 2025 10:34:46.
greenlet.cpp File 10996 bytes May 23 2025 10:34:46.
greenlet.h File 4755 bytes May 23 2025 10:34:46.
greenlet_allocator.hpp File 1582 bytes May 23 2025 10:34:46.
greenlet_compiler_compat.hpp File 4346 bytes May 23 2025 10:34:46.
greenlet_cpython_compat.hpp File 4068 bytes May 23 2025 10:34:46.
greenlet_exceptions.hpp File 4503 bytes May 23 2025 10:34:46.
greenlet_internal.hpp File 2709 bytes May 23 2025 10:34:46.
greenlet_refs.hpp File 34436 bytes May 23 2025 10:34:46.
greenlet_slp_switch.hpp File 3198 bytes May 23 2025 10:34:46.
greenlet_thread_support.hpp File 867 bytes May 23 2025 10:34:46.
slp_platformselect.h File 3841 bytes May 23 2025 10:34:46.

Reading File: //opt//hc_python/lib64//python3.12/site-packages/greenlet/TMainGreenlet.cpp

/* -*- indent-tabs-mode: nil; tab-width: 4; -*- */
/**
 * Implementation of greenlet::MainGreenlet.
 *
 * Format with:
 *  clang-format -i --style=file src/greenlet/greenlet.c
 *
 *
 * Fix missing braces with:
 *   clang-tidy src/greenlet/greenlet.c -fix -checks="readability-braces-around-statements"
*/
#ifndef T_MAIN_GREENLET_CPP
#define T_MAIN_GREENLET_CPP

#include "TGreenlet.hpp"



// Protected by the GIL. Incremented when we create a main greenlet,
// in a new thread, decremented when it is destroyed.
static Py_ssize_t G_TOTAL_MAIN_GREENLETS;

namespace greenlet {
greenlet::PythonAllocator<MainGreenlet> MainGreenlet::allocator;

void* MainGreenlet::operator new(size_t UNUSED(count))
{
    return allocator.allocate(1);
}


void MainGreenlet::operator delete(void* ptr)
{
    return allocator.deallocate(static_cast<MainGreenlet*>(ptr),
                                1);
}


MainGreenlet::MainGreenlet(PyGreenlet* p, ThreadState* state)
    : Greenlet(p, StackState::make_main()),
      _self(p),
      _thread_state(state)
{
    G_TOTAL_MAIN_GREENLETS++;
}

MainGreenlet::~MainGreenlet()
{
    G_TOTAL_MAIN_GREENLETS--;
    this->tp_clear();
}

ThreadState*
MainGreenlet::thread_state() const noexcept
{
    return this->_thread_state;
}

void
MainGreenlet::thread_state(ThreadState* t) noexcept
{
    assert(!t);
    this->_thread_state = t;
}


const BorrowedMainGreenlet
MainGreenlet::main_greenlet() const
{
    return this->_self;
}

BorrowedMainGreenlet
MainGreenlet::find_main_greenlet_in_lineage() const
{
    return BorrowedMainGreenlet(this->_self);
}

bool
MainGreenlet::was_running_in_dead_thread() const noexcept
{
    return !this->_thread_state;
}

OwnedObject
MainGreenlet::g_switch()
{
    try {
        this->check_switch_allowed();
    }
    catch (const PyErrOccurred&) {
        this->release_args();
        throw;
    }

    switchstack_result_t err = this->g_switchstack();
    if (err.status < 0) {
        // XXX: This code path is untested, but it is shared
        // with the UserGreenlet path that is tested.
        return this->on_switchstack_or_initialstub_failure(
            this,
            err,
            true, // target was me
            false // was initial stub
        );
    }

    return err.the_new_current_greenlet->g_switch_finish(err);
}

int
MainGreenlet::tp_traverse(visitproc visit, void* arg)
{
    if (this->_thread_state) {
        // we've already traversed main, (self), don't do it again.
        int result = this->_thread_state->tp_traverse(visit, arg, false);
        if (result) {
            return result;
        }
    }
    return Greenlet::tp_traverse(visit, arg);
}

const OwnedObject&
MainGreenlet::run() const
{
    throw AttributeError("Main greenlets do not have a run attribute.");
}

void
MainGreenlet::run(const BorrowedObject UNUSED(nrun))
{
   throw AttributeError("Main greenlets do not have a run attribute.");
}

void
MainGreenlet::parent(const BorrowedObject raw_new_parent)
{
    if (!raw_new_parent) {
        throw AttributeError("can't delete attribute");
    }
    throw AttributeError("cannot set the parent of a main greenlet");
}

const OwnedGreenlet
MainGreenlet::parent() const
{
    return OwnedGreenlet(); // null becomes None
}

}; // namespace greenlet

#endif

SILENT KILLER Tool