Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3610090
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T21:42:32+00:00 2026-05-18T21:42:32+00:00

I am trying to design a bot for an application called Virtual Paradise and

  • 0

I am trying to design a bot for an application called Virtual Paradise and the SDK that is given for building the bot is compiled into a shared library, therefore I have to use ctypes.

when I use

import threading
...
from ctypes import CDLL, CFUNCTYPE, c_char_p, c_int, c_void_p
vp = CDLL("libvpsdk.so")
vp.vp_string.restype = c_char_p
vp.vp_int.restype = c_int
...
class bot(threading.Thread):
    def initBot(self):
        ...
        instance = vp.vp_create()
        ...
        EventFunc = CFUNCTYPE(None)
        event_chat_func = EventFunc(self.event_chat)
        vp.vp_event_set(instance, 0, event_chat_func)
        ...
    def event_chat(self):
        print "Hello"
        ...

event_chat gets called correctly and prints “Hello”

but when I use this

import threading
import chat
...
from ctypes import CDLL, CFUNCTYPE, c_char_p, c_int, c_void_p
vp = CDLL("libvpsdk.so")
vp.vp_string.restype = c_char_p
vp.vp_int.restype = c_int
...
class bot(threading.Thread):
    def initBot(self):
        ...
        instance = vp.vp_create()
        ...
        chat.VPSDK(vp, instance)
        ...

Chat.py:

from ctypes import CFUNCTYPE
...
class VPSDK:
    def __init__(self, vp, instance):
        EventFunc = CFUNCTYPE(None)
        event_chat_func = EventFunc(self.event_chat)
        vp.vp_event_set(instance, 0, event_chat_func)

    def event_chat(self):
        print "Hello"
        ...

I get the error “Illegal instruction”

What am I doing wrong!? I need to use this separate class, otherwise other parts of my bot will loose functionality.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T21:42:32+00:00Added an answer on May 18, 2026 at 9:42 pm

    You must maintain a reference to the wrapped function for the lifetime it may be called. See the Important note… at the end of 15.16.1.17. Callback functions in the Python ctypes documentation.

    One way is to use self.event_chat_func instead, storing it for the lifetime of the containing object.

    Also, creating chat.VPSDK(vp, instance) creates an instance of chat.VPSDK that goes out of scope in the next line. You don’t demonstrate how bot is instantiated in the first example, but the VPSDK object doesn’t live very long.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to design an application based on the OpenSocial API , and I'm
I'm trying to design a model for a application allowing 2 people to bet
I'm trying to design a homepage for an MVC site that has two different
I'm trying to design some tables to store some data, which has to be
I've been trying to design a database schema for a side project but I
I am trying to design a location lookup in which the user can specify
I'm trying to design a form which contains a dropdown box containing a list
i m trying to design a mmo game using python... I have evaluated stackless
I am trying to design an object model (for C#), and can't work out
I'm trying to design a database for a sports meeting. I think I've got

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.